Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nix flake #23

Open
wants to merge 5 commits into
base: hevm-transactions
Choose a base branch
from
Open

nix flake #23

wants to merge 5 commits into from

Conversation

d-xo
Copy link

@d-xo d-xo commented Sep 26, 2023

Adds a flake.nix that uses: https://github.com/srid/haskell-flake/. This is (imo) a pretty nice nix library that lets you write clean and declarative flakes for haskell projects. It does introduce some magic and additional abstraction which may or may not be worth it depending on your tastes. It does make it harder to do some more complex or lower level stuff (e.g. building fully static binaries will probably be hard or not work at all with this framework).

Apologies if this pr muddies the waters somewhat, I only realised that #20 existed once this was already written. In comparison to #20, this is a fully cabal based flake, and completely removes all dependencies on stack. Dependencies are parsed out from the cabal file and then pulled from the nixpkgs haskell snapshot instead of the stackage lts snapshots.

This pr only adds a flake, and so requires that anyone using it has the flakes features enabled in their nix instalation. Compatibility with the legacy nix commands could easily be provided using https://github.com/edolstra/flake-compat if desired.

There are two workflows:

  • nix build: builds the project in a completely isolated nix based sandbox (this is essentially a highly restricted docker container)
  • nix develop: prepares a development shell with all required dependencies preinstalled (including ghc / cabal / haskell language server). Once inside this shell, you can build with cabal build and enter a repl with cabal repl

Preparing the dev shell currently takes an outrageous amount of time (~1hr). This work needs to be done only once, and can be cached subsequently, but it's still obviously pretty painful. I suspect that this time is due to two things:

  1. the usage of ghc-9.2.7 (afaik nixpkgs has much better caching for ghc-9.2.8)
  2. the dependency on poly which is currently marked as broken in nixpkgs (it seems as though some of the test suite is failing, not sure if that is of concern or not). This would ideally be investigated further and fixed upstream.

I also added a .envrc file which provides a pretty nice workflow where it will automatically enter the development environment for this flake as soon as you cd into the repo root.

@andrevidela andrevidela force-pushed the hevm-transactions branch 2 times, most recently from f9ec2d8 to f516590 Compare December 27, 2023 18:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant