Old GHC, Stack, and NixOS

Hello,

This is more of a Haskell and Stack question than a Nix question, so I’m gonna post it here instead of NixOS discouse.

Recently, GHC 8.6.5 was dropped from nixpkgs master branch. I added it back via an overlay, but the problem is, stack refuses to use that particular instance of GHC 8.6.5 on NixOS.

Is there a way to force stack to use system ghc on NixOS while still using Nix for other packages?

Could you link to the project you’re trying to get working?

If all you want to do is force stack to use the system ghc, there is a command line flag for that (as well as an option you can throw in stack.yaml):

However, it might just be easier for you to write a stack-shell.nix file where you can pin the GHC version you require:

I have a project where I do something similar to this. It is somewhat complicated, but hopefully it will give you something to poke around with:

1 Like

No, unfortunately I can’t link it due to licensing reasons.

But I got this figured out. Turns out, when given --system-ghc flag on NixOS, Stack still checks whether the ghc derivation has a predefined hash. What helped is the following combination of flags in my stack.yaml.

system-ghc: true
install-ghc: false
skip-ghc-check: true
3 Likes