about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2017-06-19T12·24+0200
committerEelco Dolstra <edolstra@gmail.com>2017-06-19T12·26+0200
commit1888f7889b107ecbca7ad47f3a1132c32a17d227 (patch)
tree0d35479f20c68637a5cc89f052943a46f1ec295a
parentb5bdfdef7320d74a98af1e53d64371e0cef2dbbe (diff)
macOS: Ugly hack to make the tests succeed
Sandboxes cannot be nested, so if Nix's build runs inside a sandbox,
it cannot use a sandbox itself. I don't see a clean way to detect
whether we're in a sandbox, so use a test-specific hack.

https://github.com/NixOS/nix/issues/1413
-rw-r--r--src/libstore/build.cc5
-rw-r--r--tests/common.sh.in4
2 files changed, 6 insertions, 3 deletions
diff --git a/src/libstore/build.cc b/src/libstore/build.cc
index bdec30151b08..c34083d2e2fc 100644
--- a/src/libstore/build.cc
+++ b/src/libstore/build.cc
@@ -2621,7 +2621,7 @@ void DerivationGoal::runChild()
             ;
         }
 #if __APPLE__
-        else {
+        else if (getEnv("_NIX_TEST_NO_SANDBOX") == "") {
             /* This has to appear before import statements. */
             std::string sandboxProfile = "(version 1)\n";
 
@@ -2736,13 +2736,12 @@ void DerivationGoal::runChild()
             args.push_back("_GLOBAL_TMP_DIR=" + globalTmpDir);
             args.push_back(drv->builder);
         }
-#else
+#endif
         else {
             builder = drv->builder.c_str();
             string builderBasename = baseNameOf(drv->builder);
             args.push_back(builderBasename);
         }
-#endif
 
         for (auto & i : drv->args)
             args.push_back(rewriteStrings(i, inputRewrites));
diff --git a/tests/common.sh.in b/tests/common.sh.in
index 4565a490adfd..6c3804a257a7 100644
--- a/tests/common.sh.in
+++ b/tests/common.sh.in
@@ -15,6 +15,10 @@ export NIX_STATE_DIR=$TEST_ROOT/var/nix
 export NIX_CONF_DIR=$TEST_ROOT/etc
 export NIX_MANIFESTS_DIR=$TEST_ROOT/var/nix/manifests
 export _NIX_TEST_SHARED=$TEST_ROOT/shared
+if [[ -n $NIX_STORE ]]; then
+    export _NIX_TEST_NO_SANDBOX=1
+fi
+export _NIX_IN_TEST=$TEST_ROOT/shared
 export NIX_REMOTE=$NIX_REMOTE_
 unset NIX_PATH
 export TEST_HOME=$TEST_ROOT/test-home