I’m new to Haskell and stack
. I’m trying to follow instructions for a university course that assumes Stackage snapshot LTS 14.7
These instructions weren’t made for NixOS, so I’ve translated their
stack --resolver lts-17.4 new helloworld
to
nix run 'nixpkgs#stack' -- --resolver lts-17.4 new helloworld
This gives me:
error: attribute 'ghc8104' missing
at «string»:1:43:
1| with (import <nixpkgs> {}); let inputs = [haskell.compiler.ghc8104 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";} ""
| ^
(use '--show-trace' to show detailed location information)
Fair enough. Stack has Nix integration, but probably can’t magically know which nixpkgs version contains what GHC version. It looks like NixOS 21.05 had GHC 8.10.4 (haskell.compiler.ghc8104
), even though it doesn’t show up in search.nixos.org/packages:
So I’ve tried
nix run 'github:NixOS/nixpkgs/nixos-21.05#stack' -- --resolver lts-17.4 new helloworld
but still got
error: attribute 'ghc8104' missing
at «string»:1:43:
1| with (import <nixpkgs> {}); let inputs = [haskell.compiler.ghc8104 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";} ""
| ^
(use '--show-trace' to show detailed location information)
even though
nix run 'github:NixOS/nixpkgs/nixos-21.05#haskell.compiler.ghc8104' -- --version
works just fine and gives me
The Glorious Glasgow Haskell Compilation System, version 8.10.4
Does the flake selection have no effect on Nix evaluations performed by stack
thusly invoked?
Do I have to write a shell.nix
(or flake.nix
) and pin nixpkgs
therein? I thought due to stack
's nix integration, I might get around that.