input-output-hk / stack2nix

Generate nix expressions for Haskell projects
MIT License
98 stars 32 forks source link

How to deal with missing ghc version on Nix? #166

Open wizzup opened 5 years ago

wizzup commented 5 years ago

Try to convert gloss project to nix expression and got following error

$ stack2nix --version
stack2nix 0.2.2

$ stack2nix --stack-yaml stack-8.6.yaml . --verbose

Ensuring git version is >= 2 ...
Ensuring cabal version is >= 2 ...
stack2nix (isLocalRepo): True
stack2nix (projRoot): "."
stack2nix (argUri): "."
handleStackConfig (cwd): /data/learn/haskell/gloss
handleStackConfig (localDir): .
handleStackConfig (remoteUri): Nothing
handleStackConfig (alreadyExists): True
stack2nix: haskell.compiler.ghc861 failed to build via nix
CallStack (from HasCallStack):
  error, called at src/Stack2nix/Util.hs:79:22 in stack2nix-0.2.2-EjYkwZMOavSKQ5oHK3VyZt:Stack2nix.Util

I am on NixOS but my channel no longer have ghc861 for a very long time after many updates

$ nix-env -qaPA nixos.haskell.compiler
nixos.haskell.compiler.ghc822                  ghc-8.2.2
nixos.haskell.compiler.integer-simple.ghc822   ghc-8.2.2
nixos.haskell.compiler.ghc822Binary            ghc-8.2.2-binary
nixos.haskell.compiler.ghc844                  ghc-8.4.4
nixos.haskell.compiler.ghc863Binary            ghc-8.6.3-binary
nixos.haskell.compiler.ghc864                  ghc-8.6.4
nixos.haskell.compiler.integer-simple.ghc864   ghc-8.6.4
nixos.haskell.compiler.ghc865                  ghc-8.6.4.20190406
nixos.haskell.compiler.integer-simple.ghc865   ghc-8.6.4.20190406
nixos.haskell.compiler.ghcHEAD                 ghc-8.7.20190115
nixos.haskell.compiler.integer-simple.ghcHEAD  ghc-8.7.20190115
nixos.haskell.compiler.ghcjs84                 ghcjs-8.4.0.1
nixos.haskell.compiler.ghcjs                   ghcjs-8.6.0.1
purefn commented 5 years ago

@wizzup I worked around this by specifying a NIX_PATH that I know has the right ghc in it. In my case, I needed something with ghc 8.6.3 but in the nixpkgs for my user it has been dropped and replaced with 8.6.4. So I had to backtrack and find a revision with 8.6.3 in it and use that.

NIX_PATH=nixpkgs=https://github.com/NixOS/nixpkgs/archive/68be6bbc31351a4cf5b6431d746dc390ed29c16c.tar.gz stack2nix .

HTH

wizzup commented 5 years ago

@purefn Thanks, That's one way to do it. I end-up edit the stack.yaml to use the one that matched my current version (lts-13.21).

https://www.stackage.org/

domenkozar commented 5 years ago

I think if stack2nix can't build deps it should have a better error message.