about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/build-remote/build-remote.cc4
-rw-r--r--src/libstore/build.cc12
-rw-r--r--src/libstore/globals.hh3
3 files changed, 10 insertions, 9 deletions
diff --git a/src/build-remote/build-remote.cc b/src/build-remote/build-remote.cc
index 1ee8a625b6bc..c41383bcf27d 100644
--- a/src/build-remote/build-remote.cc
+++ b/src/build-remote/build-remote.cc
@@ -140,7 +140,9 @@ int main (int argc, char * * argv)
         settings.buildTimeout = std::stoll(argv[3]);
         verbosity = (Verbosity) std::stoll(argv[4]);
 
-        currentLoad = getEnv("NIX_CURRENT_LOAD", "/run/nix/current-load");
+        /* It would be more appropriate to use $XDG_RUNTIME_DIR, since
+           that gets cleared on reboot, but it wouldn't work on OS X. */
+        currentLoad = settings.nixStateDir + "/current-load";
 
         std::shared_ptr<Store> sshStore;
         AutoCloseFD bestSlotLock;
diff --git a/src/libstore/build.cc b/src/libstore/build.cc
index a0efd880400c..9b3f799b9f2f 100644
--- a/src/libstore/build.cc
+++ b/src/libstore/build.cc
@@ -583,11 +583,7 @@ struct HookInstance
 
 HookInstance::HookInstance()
 {
-    debug("starting build hook");
-
-    Path buildHook = getEnv("NIX_BUILD_HOOK");
-    if (string(buildHook, 0, 1) != "/") buildHook = settings.nixLibexecDir + "/nix/" + buildHook;
-    buildHook = canonPath(buildHook);
+    debug("starting build hook ‘%s’", settings.buildHook);
 
     /* Create a pipe to get the output of the child. */
     fromHook.create();
@@ -621,9 +617,9 @@ HookInstance::HookInstance()
             std::to_string(verbosity)
         };
 
-        execv(buildHook.c_str(), stringsToCharPtrs(args).data());
+        execv(settings.buildHook.get().c_str(), stringsToCharPtrs(args).data());
 
-        throw SysError(format("executing ‘%1%’") % buildHook);
+        throw SysError("executing ‘%s’", settings.buildHook);
     });
 
     pid.setSeparatePG(true);
@@ -1569,7 +1565,7 @@ void DerivationGoal::buildDone()
 
 HookReply DerivationGoal::tryBuildHook()
 {
-    if (!settings.useBuildHook || getEnv("NIX_BUILD_HOOK") == "" || !useDerivation) return rpDecline;
+    if (!settings.useBuildHook || !useDerivation) return rpDecline;
 
     if (!worker.hook)
         worker.hook = std::make_unique<HookInstance>();
diff --git a/src/libstore/globals.hh b/src/libstore/globals.hh
index b4f44de2e65d..25cc3e068ee7 100644
--- a/src/libstore/globals.hh
+++ b/src/libstore/globals.hh
@@ -127,6 +127,9 @@ public:
     Setting<bool> useBuildHook{this, true, "remote-builds",
         "Whether to use build hooks (for distributed builds)."};
 
+    PathSetting buildHook{this, true, nixLibexecDir + "/nix/build-remote", "build-hook",
+        "The path of the helper program that executes builds to remote machines."};
+
     Setting<off_t> reservedSize{this, 8 * 1024 * 1024, "gc-reserved-space",
         "Amount of reserved disk space for the garbage collector."};