From b31a8f7a90ecf3a743153b5888c7f10087dca56a Mon Sep 17 00:00:00 2001 From: Silvan Mosberger Date: Wed, 13 Nov 2019 21:23:46 +0100 Subject: [PATCH 1/2] buildStackProject: Set __noChroot to make it fail without sandbox 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 --- pkgs/development/haskell-modules/generic-stack-builder.nix | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkgs/development/haskell-modules/generic-stack-builder.nix b/pkgs/development/haskell-modules/generic-stack-builder.nix index 96774f71730..45c1a8fbd33 100644 --- a/pkgs/development/haskell-modules/generic-stack-builder.nix +++ b/pkgs/development/haskell-modules/generic-stack-builder.nix @@ -20,6 +20,10 @@ let in stdenv.mkDerivation (args // { + # Doesn't work in the sandbox. Pass `--option sandbox relaxed` or + # `--option sandbox false` to be able to build this + __noChroot = true; + buildInputs = buildInputs ++ lib.optional (stdenv.hostPlatform.libc == "glibc") glibcLocales; From 27e7b9a31d8b0377797c527d133019268ee0420d Mon Sep 17 00:00:00 2001 From: Silvan Mosberger Date: Thu, 14 Nov 2019 01:30:14 +0100 Subject: [PATCH 2/2] docs/haskell: Mention buildStackProject needs a disabled sandbox --- doc/languages-frameworks/haskell.section.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/doc/languages-frameworks/haskell.section.md b/doc/languages-frameworks/haskell.section.md index 1e677450aa1..7cbac95f7d4 100644 --- a/doc/languages-frameworks/haskell.section.md +++ b/doc/languages-frameworks/haskell.section.md @@ -398,7 +398,9 @@ nix: For more on how to write a `shell.nix` file see the below section. You'll need to express a derivation. Note that Nixpkgs ships with a convenience wrapper function around `mkDerivation` called `haskell.lib.buildStackProject` to help you -create this derivation in exactly the way Stack expects. All of the same inputs +create this derivation in exactly the way Stack expects. However for this to work +you need to disable the sandbox, which you can do by using `--option sandbox relaxed` +or `--option sandbox false` to the Nix command. All of the same inputs as `mkDerivation` can be provided. For example, to build a Stack project that including packages that link against a version of the R library compiled with special options turned on: