summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2019-09-03 22:11:47 +0200
committerLudovic Courtès <ludo@gnu.org>2019-09-08 11:49:24 +0200
commitbc69ea2d605810cc32e13ed03d5848b8dc358b61 (patch)
treec4cbe1017a77ff853255d41b44301ff68c5257a1
parent9fcc35c51fd579b3bb7b4f61cba6973675c3922c (diff)
downloadpatches-bc69ea2d605810cc32e13ed03d5848b8dc358b61.tar
patches-bc69ea2d605810cc32e13ed03d5848b8dc358b61.tar.gz
daemon: Run 'guix offload' directly.
* nix/scripts/offload.in: Remove. * nix/local.mk (nodist_pkglibexec_SCRIPTS) [BUILD_DAEMON_OFFLOAD]: Remove 'scripts/offload'. * config-daemon.ac: Don't output 'nix/scripts/offload'. * build-aux/pre-inst-env.in: Don't set 'NIX_BUILD_HOOK'. * nix/libstore/build.cc (HookInstance::HookInstance): Run 'guix offload'. (DerivationGoal::tryBuildHook): Remove reference to 'NIX_BUILD_HOOK'. * nix/nix-daemon/guix-daemon.cc (main) [HAVE_DAEMON_OFFLOAD_HOOK]: Don't set 'NIX_BUILD_HOOK'. * nix/nix-daemon/nix-daemon.cc (performOp) [!HAVE_DAEMON_OFFLOAD_HOOK]: Leave 'settings.useBuildHook' unchanged.
-rw-r--r--build-aux/pre-inst-env.in4
-rw-r--r--config-daemon.ac2
-rw-r--r--nix/libstore/build.cc11
-rw-r--r--nix/local.mk7
-rw-r--r--nix/nix-daemon/guix-daemon.cc9
-rw-r--r--nix/nix-daemon/nix-daemon.cc8
-rw-r--r--nix/scripts/offload.in11
7 files changed, 13 insertions, 39 deletions
diff --git a/build-aux/pre-inst-env.in b/build-aux/pre-inst-env.in
index ab1c519d70..f96288132d 100644
--- a/build-aux/pre-inst-env.in
+++ b/build-aux/pre-inst-env.in
@@ -48,10 +48,6 @@ NIX_LIBEXEC_DIR="@abs_top_builddir@/nix/scripts" # for 'authenticate', etc.
export NIX_LIBEXEC_DIR
-NIX_BUILD_HOOK="$abs_top_builddir/nix/scripts/offload"
-@BUILD_DAEMON_OFFLOAD_TRUE@export NIX_BUILD_HOOK
-@BUILD_DAEMON_OFFLOAD_FALSE@# No offloading support.
-@BUILD_DAEMON_OFFLOAD_FALSE@unset NIX_BUILD_HOOK
# The daemon invokes 'guix'; tell it which one to use.
GUIX="$abs_top_builddir/scripts/guix"
export GUIX
diff --git a/config-daemon.ac b/config-daemon.ac
index 50227e310c..3d92e8f778 100644
--- a/config-daemon.ac
+++ b/config-daemon.ac
@@ -150,8 +150,6 @@ if test "x$guix_build_daemon" = "xyes"; then
GUIX_CHECK_LOCALSTATEDIR
AC_CONFIG_FILES([nix/scripts/substitute],
[chmod +x nix/scripts/substitute])
- AC_CONFIG_FILES([nix/scripts/offload],
- [chmod +x nix/scripts/offload])
fi
AM_CONDITIONAL([HAVE_LIBBZ2], [test "x$HAVE_LIBBZ2" = "xyes"])
diff --git a/nix/libstore/build.cc b/nix/libstore/build.cc
index fe7bf79069..9f1f88933a 100644
--- a/nix/libstore/build.cc
+++ b/nix/libstore/build.cc
@@ -614,9 +614,7 @@ 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);
+ const Path &buildHook = settings.guixProgram;
/* Create a pipe to get the output of the child. */
fromHook.create();
@@ -642,13 +640,14 @@ HookInstance::HookInstance()
if (dup2(builderOut.writeSide, 4) == -1)
throw SysError("dupping builder's stdout/stderr");
- execl(buildHook.c_str(), buildHook.c_str(), settings.thisSystem.c_str(),
+ execl(buildHook.c_str(), buildHook.c_str(), "offload",
+ settings.thisSystem.c_str(),
(format("%1%") % settings.maxSilentTime).str().c_str(),
(format("%1%") % settings.printBuildTrace).str().c_str(),
(format("%1%") % settings.buildTimeout).str().c_str(),
NULL);
- throw SysError(format("executing `%1%'") % buildHook);
+ throw SysError(format("executing `%1% offload'") % buildHook);
});
pid.setSeparatePG(true);
@@ -1581,7 +1580,7 @@ void DerivationGoal::buildDone()
HookReply DerivationGoal::tryBuildHook()
{
- if (!settings.useBuildHook || getEnv("NIX_BUILD_HOOK") == "") return rpDecline;
+ if (!settings.useBuildHook) return rpDecline;
if (!worker.hook)
worker.hook = std::shared_ptr<HookInstance>(new HookInstance);
diff --git a/nix/local.mk b/nix/local.mk
index c4c3920fa3..8e52c77bd9 100644
--- a/nix/local.mk
+++ b/nix/local.mk
@@ -157,13 +157,6 @@ noinst_HEADERS = \
nodist_pkglibexec_SCRIPTS = \
%D%/scripts/substitute
-if BUILD_DAEMON_OFFLOAD
-
-nodist_pkglibexec_SCRIPTS += \
- %D%/scripts/offload
-
-endif BUILD_DAEMON_OFFLOAD
-
# The '.service' files for systemd.
systemdservicedir = $(libdir)/systemd/system
nodist_systemdservice_DATA = etc/guix-daemon.service etc/guix-publish.service
diff --git a/nix/nix-daemon/guix-daemon.cc b/nix/nix-daemon/guix-daemon.cc
index f47d142612..73962af584 100644
--- a/nix/nix-daemon/guix-daemon.cc
+++ b/nix/nix-daemon/guix-daemon.cc
@@ -474,15 +474,8 @@ main (int argc, char *argv[])
settings.set ("substitute-urls", GUIX_SUBSTITUTE_URLS);
#ifdef HAVE_DAEMON_OFFLOAD_HOOK
- /* Use our build hook for distributed builds by default. */
+ /* Use 'guix offload' for distributed builds by default. */
settings.useBuildHook = true;
- if (getenv ("NIX_BUILD_HOOK") == NULL)
- {
- std::string build_hook;
-
- build_hook = settings.nixLibexecDir + "/offload";
- setenv ("NIX_BUILD_HOOK", build_hook.c_str (), 1);
- }
#else
/* We are not installing any build hook, so disable it. */
settings.useBuildHook = false;
diff --git a/nix/nix-daemon/nix-daemon.cc b/nix/nix-daemon/nix-daemon.cc
index 56137701a1..f29bcd2eab 100644
--- a/nix/nix-daemon/nix-daemon.cc
+++ b/nix/nix-daemon/nix-daemon.cc
@@ -580,8 +580,14 @@ static void performOp(bool trusted, unsigned int clientVersion,
settings.set("build-max-silent-time", std::to_string(readInt(from)));
}
- if (GET_PROTOCOL_MINOR(clientVersion) >= 2)
+ if (GET_PROTOCOL_MINOR(clientVersion) >= 2) {
+#ifdef HAVE_DAEMON_OFFLOAD_HOOK
settings.useBuildHook = readInt(from) != 0;
+#else
+ readInt(from); // ignore the user's setting
+#endif
+ }
+
if (GET_PROTOCOL_MINOR(clientVersion) >= 4) {
settings.buildVerbosity = (Verbosity) readInt(from);
logType = (LogType) readInt(from);
diff --git a/nix/scripts/offload.in b/nix/scripts/offload.in
deleted file mode 100644
index 50faed31c0..0000000000
--- a/nix/scripts/offload.in
+++ /dev/null
@@ -1,11 +0,0 @@
-#!@SHELL@
-# A shorthand for "guix offload", for use by the daemon.
-
-if test "x$GUIX_UNINSTALLED" = "x"
-then
- prefix="@prefix@"
- exec_prefix="@exec_prefix@"
- exec "@bindir@/guix" offload "$@"
-else
- exec guix offload "$@"
-fi