From 79f9dee3c4c0e6d21066f142116a537207ae7ba4 Mon Sep 17 00:00:00 2001 From: Mathieu Othacehe Date: Tue, 24 Nov 2020 14:05:21 +0100 Subject: Use substitute servers on the local network. * guix/scripts/discover.scm: New file. * Makefile.am (MODULES): Add it. * nix/nix-daemon/guix-daemon.cc (options): Add "discover" option, (parse-opt): parse it, (main): start "guix discover" process when the option is set. * guix/scripts/substitute.scm (%local-substitute-urls): New variable, (substitute-urls): add it. * gnu/services/base.scm (): Add "discover?" field, (guix-shepherd-service): honor it. * doc/guix.texi (Invoking guix-daemon): Document "discover" option, (Base Services): ditto. --- nix/nix-daemon/guix-daemon.cc | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'nix') diff --git a/nix/nix-daemon/guix-daemon.cc b/nix/nix-daemon/guix-daemon.cc index cd949aca67..30d0e5d11d 100644 --- a/nix/nix-daemon/guix-daemon.cc +++ b/nix/nix-daemon/guix-daemon.cc @@ -89,6 +89,7 @@ builds derivations on behalf of its clients."); #define GUIX_OPT_TIMEOUT 18 #define GUIX_OPT_MAX_SILENT_TIME 19 #define GUIX_OPT_LOG_COMPRESSION 20 +#define GUIX_OPT_DISCOVER 21 static const struct argp_option options[] = { @@ -129,6 +130,8 @@ static const struct argp_option options[] = n_("disable compression of the build logs") }, { "log-compression", GUIX_OPT_LOG_COMPRESSION, "TYPE", 0, n_("use the specified compression type for build logs") }, + { "discover", GUIX_OPT_DISCOVER, "yes/no", OPTION_ARG_OPTIONAL, + n_("use substitute servers discovered on the local network") }, /* '--disable-deduplication' was known as '--disable-store-optimization' up to Guix 0.7 included, so keep the alias around. */ @@ -167,6 +170,8 @@ to live outputs") }, /* List of '--listen' options. */ static std::list listen_options; +static bool useDiscover = false; + /* Convert ARG to a Boolean value, or throw an error if it does not denote a Boolean. */ static bool @@ -261,6 +266,10 @@ parse_opt (int key, char *arg, struct argp_state *state) case GUIX_OPT_NO_BUILD_HOOK: settings.useBuildHook = false; break; + case GUIX_OPT_DISCOVER: + useDiscover = string_to_bool (arg); + settings.set("discover", arg); + break; case GUIX_OPT_DEBUG: verbosity = lvlDebug; break; @@ -506,6 +515,18 @@ using `--build-users-group' is highly recommended\n")); format ("extra chroot directories: '%1%'") % chroot_dirs); } + if (useDiscover) + { + Strings args; + + args.push_back("guix"); + args.push_back("discover"); + + startProcess([&]() { + execv(settings.guixProgram.c_str(), stringsToCharPtrs(args).data()); + }); + } + printMsg (lvlDebug, format ("automatic deduplication set to %1%") % settings.autoOptimiseStore); -- cgit v1.2.3