From 2e3e5d21988fc2cafb2a9eaf4b00976ea425629d Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Tue, 3 Sep 2019 21:36:29 +0200 Subject: daemon: Invoke 'guix gc --list-busy' instead of 'list-runtime-roots'. * nix/scripts/list-runtime-roots.in: Remove. * guix/store/roots.scm (%proc-directory): New variable. (proc-file-roots, proc-exe-roots, proc-cwd-roots) (proc-fd-roots, proc-maps-roots, proc-environ-roots) (referenced-files, canonicalize-store-item, busy-store-items): New procedures, taken from 'list-runtime-roots.in'. * nix/libstore/globals.hh (Settings)[guixProgram]: New field. * nix/libstore/globals.cc (Settings::processEnvironment): Initialize 'guixProgram'. * nix/libstore/gc.cc (addAdditionalRoots): Drop code related to 'NIX_ROOT_FINDER'. Run "guix gc --list-busy". * nix/local.mk (nodist_pkglibexec_SCRIPTS): Remove 'scripts/list-runtime-roots'. * config-daemon.ac: Don't output nix/scripts/list-runtime-roots. * build-aux/pre-inst-env.in: Don't set 'NIX_ROOT_FINDER'. Set 'GUIX'. * doc/guix.texi (Invoking guix gc): Document '--list-busy'. * guix/scripts/gc.scm (show-help, %options): Add "--list-busy". (guix-gc)[list-busy]: New procedure. Handle the 'list-busy' action. --- build-aux/pre-inst-env.in | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'build-aux') diff --git a/build-aux/pre-inst-env.in b/build-aux/pre-inst-env.in index 3efab69e7d..ab1c519d70 100644 --- a/build-aux/pre-inst-env.in +++ b/build-aux/pre-inst-env.in @@ -44,15 +44,17 @@ export PATH # Daemon helpers. -NIX_ROOT_FINDER="$abs_top_builddir/nix/scripts/list-runtime-roots" NIX_LIBEXEC_DIR="@abs_top_builddir@/nix/scripts" # for 'authenticate', etc. -export NIX_ROOT_FINDER NIX_LIBEXEC_DIR +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 # The following variables need only be defined when compiling Guix # modules, but we define them to be on the safe side in case of -- cgit v1.2.3 From bc69ea2d605810cc32e13ed03d5848b8dc358b61 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Tue, 3 Sep 2019 22:11:47 +0200 Subject: 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. --- build-aux/pre-inst-env.in | 4 ---- config-daemon.ac | 2 -- nix/libstore/build.cc | 11 +++++------ nix/local.mk | 7 ------- nix/nix-daemon/guix-daemon.cc | 9 +-------- nix/nix-daemon/nix-daemon.cc | 8 +++++++- nix/scripts/offload.in | 11 ----------- 7 files changed, 13 insertions(+), 39 deletions(-) delete mode 100644 nix/scripts/offload.in (limited to 'build-aux') 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(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 -- cgit v1.2.3 From 82f903e70f580c34503052245625354d2f097d7e Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Wed, 4 Sep 2019 12:00:31 +0200 Subject: daemon: Remove 'NIX_LIBEXEC_DIR'. * nix/libstore/globals.hh (Settings)[nixLibexecDir]: Remove. * nix/libstore/globals.cc (Settings::processEnvironment): Remove reference to 'nixLibexecDir'. * nix/local.mk (libstore_a_CPPFLAGS): Remove -DNIX_LIBEXEC_DIR flag. * build-aux/pre-inst-env.in: Remove references to 'NIX_LIBEXEC_DIR'. --- build-aux/pre-inst-env.in | 6 ------ nix/libstore/globals.cc | 1 - nix/libstore/globals.hh | 3 --- nix/local.mk | 1 - 4 files changed, 11 deletions(-) (limited to 'build-aux') diff --git a/build-aux/pre-inst-env.in b/build-aux/pre-inst-env.in index f96288132d..e0aa7fe868 100644 --- a/build-aux/pre-inst-env.in +++ b/build-aux/pre-inst-env.in @@ -42,12 +42,6 @@ export GUILE_LOAD_COMPILED_PATH GUILE_LOAD_PATH PATH="$abs_top_builddir/scripts:$abs_top_builddir:$PATH" export PATH -# Daemon helpers. - -NIX_LIBEXEC_DIR="@abs_top_builddir@/nix/scripts" # for 'authenticate', etc. - -export NIX_LIBEXEC_DIR - # The daemon invokes 'guix'; tell it which one to use. GUIX="$abs_top_builddir/scripts/guix" export GUIX diff --git a/nix/libstore/globals.cc b/nix/libstore/globals.cc index 8f7c976fcb..0cc001fbe4 100644 --- a/nix/libstore/globals.cc +++ b/nix/libstore/globals.cc @@ -70,7 +70,6 @@ void Settings::processEnvironment() nixStateDir = canonPath(getEnv("GUIX_STATE_DIRECTORY", NIX_STATE_DIR)); nixDBPath = getEnv("GUIX_DATABASE_DIRECTORY", nixStateDir + "/db"); nixConfDir = canonPath(getEnv("GUIX_CONFIGURATION_DIRECTORY", GUIX_CONFIGURATION_DIRECTORY)); - nixLibexecDir = canonPath(getEnv("NIX_LIBEXEC_DIR", NIX_LIBEXEC_DIR)); nixBinDir = canonPath(getEnv("NIX_BIN_DIR", NIX_BIN_DIR)); nixDaemonSocketFile = canonPath(nixStateDir + DEFAULT_SOCKET_PATH); guixProgram = canonPath(getEnv("GUIX", nixBinDir + "/guix")); diff --git a/nix/libstore/globals.hh b/nix/libstore/globals.hh index 0069c85956..27616a2283 100644 --- a/nix/libstore/globals.hh +++ b/nix/libstore/globals.hh @@ -57,9 +57,6 @@ struct Settings { /* The directory where configuration files are stored. */ Path nixConfDir; - /* The directory where internal helper programs are stored. */ - Path nixLibexecDir; - /* The directory where the main programs are stored. */ Path nixBinDir; diff --git a/nix/local.mk b/nix/local.mk index 18e9ba7604..dc5a8398b2 100644 --- a/nix/local.mk +++ b/nix/local.mk @@ -110,7 +110,6 @@ libstore_a_CPPFLAGS = \ -DNIX_STATE_DIR=\"$(localstatedir)/guix\" \ -DNIX_LOG_DIR=\"$(localstatedir)/log/guix\" \ -DGUIX_CONFIGURATION_DIRECTORY=\"$(sysconfdir)/guix\" \ - -DNIX_LIBEXEC_DIR=\"$(libexecdir)/guix\" \ -DNIX_BIN_DIR=\"$(bindir)\" \ -DDEFAULT_CHROOT_DIRS="\"\"" -- cgit v1.2.3