I’m a fairly competent Haskell developer, but brand new to nix.
I have a NixOS machine, which I’ve hitherto managed to configure nicely, mostly by using various recipes etc.
While I’m still working on climbing up the nix learning curve, I’ve had a need to build and deploy a Haskell yesod app.
As I’m quite familiar with stack, I figured I’d reach for that first, as it has a nix integration. I was fairly quickly able (apparently) to build my project with the nix integration. I realize that it doesn’t have all the advantages of incremental building and caching of the dependency artefacts, but it’s the path of least resistance to me.
My shell-file (default.nix) is just the one suggested in the stack docs:
{ghc}:
with (import { });
haskell.lib.buildStackProject {
inherit ghc;
name = “scoti2”;
src = ./.;
buildInputs = [ openssl postgresql zlib ];
}
However, when it came time to integrate this into my NixOS configuration.nix, I thought I’d pull the project in from its repo and put this prefix in that file:
let
scoti2Project = builtins.fetchGit {
url = “”;
rev = “”;
# Or you can use fetchSubmodules = true;
if your project uses Git submodules.
};
myScoti2 = pkgs.callPackage “${scoti2Project}/default.nix” {};
… and I then use myScoti2 later in the configuration.nix (specifically in an attempt to configure the keter service).
The problem I’m getting is the error:
error: derivation ‘/nix/store/yasp23bhaqc53l508xdki8iq24aalxf7-scoti2.drv’ has ‘__noChroot’ set, but that’s not allowed when ‘sandbox’ is ‘true’
It is my understanding that stack uses a non-sandbox build method in order to give it the freedom to use the network during the build process in order to satisfy dependencies by downloading packages from the internet, and this is why __noChroot is set, but that this is incompatible with the outer build context of my configuration.nix.
Not having the required nix-fu (yet!), I’m rather stuck. An amount of googling around hasn’t really revealed the answer either, so I’m asking for help here.
Is there any way to somehow separate the part of the build that will be done by stack, from the part that seems to be want the sandbox build somehow?.. or perhaps some other nix magic? Or maybe I’m just living wrong and somebody can correct my errant ways
Thanks in advance.
– Luke