To get past your immediate error, you can use the Nix option --option sandbox relaxed
. This turns off the sandboxing for your Stack build.
Although, most people using Haskell with Nix don’t use the generic stack builder from Nixpkgs. One of the main reasons is the requirement that you turn off sandboxing!
So what are your options for building Haskell projects with Nix? I have a small list here:
If you absolutely want to build a stack-based project with Nix, you have three main options:
-
Pick a version of Nixpkgs that uses the same LTS version your project is based on, and then use
haskellPackages.developPackage
orhaskellPackages.shellFor
for building your project. -
Use haskell.nix. This has very good support for building from a
stack.yaml
file. The downside is that it can be quite complex. -
Use stacklock2nix. This is a little simpler than haskell.nix (although I’d hesitate to say that it is “beginner-oriented”).