error:
… while calling the 'derivationStrict' builtin
at /builtin/derivation.nix:9:12: (source not available)
… while evaluating derivation 'myEnv'
whose name attribute is located at /nix/store/4qviwiyv0ylfn50l2wvmc0zykr8g1fps-nixos-23.05/nixos/pkgs/stdenv/generic/make-derivation.nix:303:7
… while evaluating attribute 'LD_LIBRARY_PATH' of derivation 'myEnv'
at «string»:1:411:
1| with (import <nixpkgs> {}); let inputs = [haskell.compiler.ghc963 git gcc gmp]; libPath = lib.makeLibraryPath inputs; stackExtraArgs = lib.concatMap (pkg: [ ''--extra-lib-dirs=${lib.getLib pkg}/lib'' ''--extra-include-dirs=${lib.getDev pkg}/include'' ]) inputs; in runCommand ''myEnv'' { buildInputs = lib.optional stdenv.isLinux glibcLocales ++ inputs; STACK_PLATFORM_VARIANT=''nix''; STACK_IN_NIX_SHELL=1; LD_LIBRARY_PATH = libPath;STACK_IN_NIX_EXTRA_ARGS = stackExtraArgs; LANG="en_US.UTF-8";} ""
| ^
error: attribute 'ghc963' missing
at «string»:1:43:
1| with (import <nixpkgs> {}); let inputs = [haskell.compiler.ghc963 git gcc gmp]; libPath = lib.makeLibraryPath inputs; stackExtraArgs = lib.concatMap (pkg: [ ''--extra-lib-dirs=${lib.getLib pkg}/lib'' ''--extra-include-dirs=${lib.getDev pkg}/include'' ]) inputs; in runCommand ''myEnv'' { buildInputs = lib.optional stdenv.isLinux glibcLocales ++ inputs; STACK_PLATFORM_VARIANT=''nix''; STACK_IN_NIX_SHELL=1; LD_LIBRARY_PATH = libPath;STACK_IN_NIX_EXTRA_ARGS = stackExtraArgs; LANG="en_US.UTF-8";} ""
| ^
Did you mean one of ghc943, ghc96, ghc961, ghc962 or ghc90?
I tried to set languages.haskell.package to one of the suggested compilers like ghc96 but I’m still getting the error message. What am I doing wrong?
If you run stack --verbose build you should be able to see how stack is trying to run nix-shell to pull in GHC for you.
If the Nix channel that the underlying nix-shell doesn’t have the version of GHC you need, you’ll see this error.
There are a couple ways to fix this, but the underlying idea is to either switch your stack resolver to a version that uses a GHC contained in the Nixpkgs that nix-shell is trying to use. Or, switch your Nixpkgs version to a version that contains the GHC version that stack wants.
You can see that nix-shell is effectively just importing <nixpkgs>. You need to make sure that you’re either running it in an environment where your NIX_PATH is set to something that contains a version of Nixpkgs that contains the version of GHC you’re trying to use, or make the inner call to nix-shell not rely on <nixpkgs>.
I’m not sure what the recommended way to do this is with devenv, but here is the Stack documentation on the topic:
You should be able to find a lot of people describing the same topic if you google for something like “stack nixpkgs ghc attribute missing Did you mean one of”.
You can see that nix-shell is effectively just importing <nixpkgs>. You need to make sure that you’re either running it in an environment where your NIX_PATH is set to something that contains a version of Nixpkgs that contains the version of GHC you’re trying to use, or make the inner call to nix-shell not rely on <nixpkgs>.
ooh. Well, both are things I don’t know how to fix that xD
I’m not sure what the recommended way to do this is with devenv, but here is the Stack documentation on the topic:
holy shit, I just copied their flake.nix and adjusted the version of ghc and it works! Thanks man!