Building such a derivation will result in
error: derivation '/nix/store/nk4wms3hk4mp9lc86k30vc8w44fcq0rj-foo.drv' has '__noChroot' set, but that's not allowed when 'sandbox' is 'true'
when attempting to build it without --option sandbox false
We need to add the STACK_IN_NIX_EXTRA_ARGS hook in configurePhase also to ensure we get the right args when calling ```nix-build``` (as opposed to nix-shell).
`stack setup` should not be called inside `nix-build` because
that makes stack download a GHC instead of using nix's one
(the one provided `generic-stack-builder.nix` as the `ghc` argument),
which will not work.
Further evidence for this is that the `stack --nix` support
intentionally uses `--system-ghc` for the same purpose.
generic-stack-builder was not setting STACK_PLATFORM_VARIANT="nix".
This is required by stack when handling its haskell packages database
snapshot. Stack must keep separated packages built with its own GHC
and those built with GHC from Nixpkgs.
Previously, the user could only compile using the default version of
GHC in Nixpkgs. Now this can be changed by setting the `ghc` attribute
appropriately.