I am attempting to build my haskell project on NixOS.
Running $ stack build
gives the following error.
$ stack build
error: attribute ‘ghc82
You can provide an old GHC version using a shell.nix
file place in the root of your project:
with import (fetchTarball https://github.com/NixOS/nixpkgs/archive/83b35508c6491103cd16a796758e07417a28698b.tar.gz) {};
let ghc = haskell.compiler.ghc802;
in haskell.lib.buildStackProject {
inherit ghc;
name = "myEnv";
buildInputs = [ pcre ];
}
Use a tar url from https://github.com/NixOS/nixpkgs/releases for a version of nixpkgs that contains the GHC version you need.
Then run nix-shell
in the root of the project. This will put you into a shell in which you can perform stack build
successfully since it would have access to the correct GHC version.