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

Migrate nix environment to flakes #604

Merged
merged 10 commits into from
Jun 23, 2022
Merged

Migrate nix environment to flakes #604

merged 10 commits into from
Jun 23, 2022

Conversation

walkah
Copy link
Member

@walkah walkah commented Jun 7, 2022

Closes #584

Adding flake.nix for faster nix-shell startup and better version pinning. In the process, generally cleaning up some issues (mostly around aarch64-darwin):

  • Remove rosetta arg for building natively on M1
  • Make sure HLS works in multiple environments
  • remove the --nix vs --no-nix dance for stack (if you're using nix, automatically build with --nix but otherwise let folks use stack as normal).

openssl
postgresql
zlib
] ++ macos;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't need ncurses etc for the CLI?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess VERY WIP — okay fair!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

builds without for me ™️ ... but yeah, WIP because (amongst other things) I've only built it on my new m1 macbook pro so far.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@walkah interesting! Does it build with --pure enabled?

flake.nix Outdated
wrapProgram $out/bin/stack \
--add-flags "\
--nix \
--no-nix-pure \
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@expede explicitly without pure so far (because that's not working on aarch64-darwin for me yet)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@walkah Ah, gotcha. Do you possibly have ncurses etc installed system wide?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, I can just leave you to your hacking on the problem until you're further along 😅 Just say the word!

@walkah walkah marked this pull request as ready for review June 16, 2022 18:19
Copy link
Contributor

@bgins bgins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing! This new setup is working great on my M1 mac. I tested:

  • ✅ Enter a nix shell with nix-shell (no rosetta flag)
  • ✅ Build with the build command, no flags or tweaking nix integrations
  • ✅ Tests run with quality
  • ✅ Haskell Language Server starts up when opening the project in VSCode, without entering the nix shell to and opening VSCode from there. (Note: The language server did not work immediately, only after the initial nix-shell and closing and re-opening VSCode.)

Huge improvement! Thanks for making this way better! 🙏 🙏 🙏

@matheus23
Copy link
Member

I can nix-shell successfully, but I can't run build:

[...]
Only                             > configure
Only                             > /home/philipp/.stack/setup-exe-cache/x86_64-linux-nix/Cabal-simple_mPHDZzAJ_3.2.1.0_ghc-8.10.7: error while loading shared libraries: libgmp.so.10: cannot open shared object file: No such file or directory
SHA                              > configure
SHA                              > /home/philipp/.stack/setup-exe-cache/x86_64-linux-nix/Cabal-simple_mPHDZzAJ_3.2.1.0_ghc-8.10.7: error while loading shared libraries: libgmp.so.10: cannot open shared object file: No such file or directory
StateVar                         > configure
StateVar                         > /home/philipp/.stack/setup-exe-cache/x86_64-linux-nix/Cabal-simple_mPHDZzAJ_3.2.1.0_ghc-8.10.7: error while loading shared libraries: libgmp.so.10: cannot open shared object file: No such file or directory
appar                            > configure
appar                            > /home/philipp/.stack/setup-exe-cache/x86_64-linux-nix/Cabal-simple_mPHDZzAJ_3.2.1.0_ghc-8.10.7: error while loading shared libraries: libgmp.so.10: cannot open shared object file: No such file or directory
Progress 4/305       
[...]

I have a file /usr/lib/libgmp.so.10. Is there something in the nix-shell preventing it from picking that one up? Should there be a libgmp.so.10 in the include path inside the nix-shell perhaps?

@walkah
Copy link
Member Author

walkah commented Jun 20, 2022

I can nix-shell successfully, but I can't run build:

One change is that we now run stack in a "pure" nix shell ... which seems to be working in our CI environments. My best guess is that you have a cached build that was built against your system libgmp (which will be unavailable in the pure shell). Can you try a clean build? (I know that's a long build)

@matheus23
Copy link
Member

I'm feeling dumb. How would I clean my cache? I've tried removing all .stack-work directories I could find, but I get the same errors.

I also tried nix-shell --pure. That loads fine but when I run build I get an error about nix-shell not being on my PATH. When I just add it, then it goes back to the previous error. You said that libgmp.so.10 should be unavailable from a pure shell. I think that's the case: The error says it can't find libgmp.so.10.

I saw that behind the build command there's stack build --nix. I also tried running stack build without --nix directly, but that didn't work.


Okay, I removed my ~/.stack directory now. That seems to run something. Will report back soon (maybe tomorrow).

Copy link
Member

@matheus23 matheus23 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing my ~/.stack directory and re-running everything worked! :)

Thanks 👍

Ship it!
Ship

@walkah
Copy link
Member Author

walkah commented Jun 20, 2022

Removing my ~/.stack directory and re-running everything worked! :)

Awesome! Glad to hear it! @expede you okay if I merge this? (I know you were testing it out too)

@walkah walkah merged commit 6b78568 into main Jun 23, 2022
@walkah walkah deleted the walkah/nix-flakes branch June 23, 2022 19:28
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.

Add flake.nix for those running new Nix commands
4 participants