From 6b09bef83bdf1882457d4ec91a761a2603f2c1d4 Mon Sep 17 00:00:00 2001 From: Maxime Devos Date: Thu, 25 Feb 2021 21:03:19 +0100 Subject: [PATCH 3/4] daemon: Set the 'substitute-methods' option. This option is used by 'guix substitute' to determine which substitution methods to use. * doc/guix.texi (Invoking guix-daemon): Document the new daemon option "--substitute-methods". (Getting Substitutes from Other Protocols): Document how to use non-HTTP and non-HTTPS substituters. * doc/substituters.texi: Remove TODO fixed by this commit. * nix/nix-daemon/guix-daemon.cc (GUIX_OPT_SUBSTITUTE_METHODS, options, parse_opt): Define a new option "--substitute-methods" and include its value in the "substitute-methods" daemon option. --- doc/guix.texi | 48 +++++++++++++++++++++++++++++++++++ doc/substituters.texi | 6 ----- nix/nix-daemon/guix-daemon.cc | 7 +++++ 3 files changed, 55 insertions(+), 6 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 591dc320d8..c811eb1025 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -229,6 +229,7 @@ Substitutes * Official Substitute Server:: One particular source of substitutes. * Substitute Server Authorization:: How to enable or disable substitutes. * Getting Substitutes from Other Servers:: Substitute diversity. +* Getting Substitutes from Other Protocols:: Different sources of substitutes. * Substitute Authentication:: How Guix verifies substitutes. * Proxy Settings:: How to get substitutes via proxy. * Substitution Failure:: What happens when substitution fails. @@ -1531,6 +1532,19 @@ as they are signed by a trusted signature (@pxref{Substitutes}). @xref{Getting Substitutes from Other Servers}, for more information on how to configure the daemon to get substitutes from other servers. +@item --substitute-methods=@var{methods} +Consider @var{methods} the whitespace-separated list of substitution +methods (‘substituters’) to use. When this option is omitted, @code{http} +is used. The @code{http} substituter supports both the HTTP and HTTPS +protocol. + +@xref{Defining Substituters} for information on how to define new +substituters, and @pxref{Getting Substitutes from Other Protocols} +on how to use non-HTTP and non-HTTPS substituters. + +@c TODO: see
for information on how to configure the +@c IPFS and GNUnet substituters + @cindex offloading @item --no-offload Do not use offload builds to other machines (@pxref{Daemon Offload @@ -3679,6 +3693,7 @@ also result from derivation builds, can be available as substitutes. * Official Substitute Server:: One particular source of substitutes. * Substitute Server Authorization:: How to enable or disable substitutes. * Getting Substitutes from Other Servers:: Substitute diversity. +* Getting Substitutes from Other Protocols:: Different sources of substitutes. * Substitute Authentication:: How Guix verifies substitutes. * Proxy Settings:: How to get substitutes via proxy. * Substitution Failure:: What happens when substitution fails. @@ -3885,6 +3900,39 @@ Note that there are also situations where one may want to add the URL of a substitute server @emph{without} authorizing its key. @xref{Substitute Authentication}, to understand this fine point. +@node Getting Substitutes from Other Protocols +@subsection Getting Substitutes from Other Protocols + +@cindex substitute servers, alternative protocols +This subsection probably won't make much sense yet, +as currently only the HTTP and HTTPS protocols are supported +for substitution. Consider what follows as a peek into the future! + +Guix will support multiple substitution methods -- currently only +a substituter for HTTP and HTTPS is defined, but a substituter for +the P2P networks IPFS and GNUnet will be defined in the future. + +@c The IPFS substituter has actually already been implemented, +@c see http://issues.guix.gnu.org/33899, but it requires some changes +@c and is not yet available to the end-user. +In order to use a substition method, it must first be enabled in the +guix daemon +(@pxref{Invoking guix-daemon, @option{--substitute-methods}}). +For example, to enable the HTTP/S and the yet-to-be-written IPFS +substituter, pass @code{--substitute-methods='http ipfs'}. +This must be set in the daemon, and cannot be done from a user process. +@c XXX ^ is this sentence clear? I mean ``guix build --substitute-methods`` +@c won't work, as substitution happens in the daemon (well, in a process +@c started by the daemon to be precise). + +Also include an URL supported by the substituter in the list of +substitute server URLs. That's all there is to it! + +@c TODO ^ when using the IPFS substituter, the daemon also needs - +@c to know the IPFS gateway, and when using the GNUnet substituter, +@c GNUnet needs to be running. But let's first actually implement +@c & merge these substituters ... + @node Substitute Authentication @subsection Substitute Authentication diff --git a/doc/substituters.texi b/doc/substituters.texi index f86a1cb26c..516e2c1eea 100644 --- a/doc/substituters.texi +++ b/doc/substituters.texi @@ -12,12 +12,6 @@ module. In order to let the daemon actually find the substituter, the substituter should be defined in a module @code{(guix scripts substitute name)}, as a variable @var{name}-substituter. -@c TODO currently unimplemented -@c -@c The @code{substitute-methods} daemon option must also be set to a -@c space-separated list of the names of the substituters to use. This is -@c currently unimplemented. - @deffn {Scheme Procedure} make-substituter @var{name} @var{nar-downloader} @ @var{fetch-narinfos} @var{recognised-uri-schemes} Return a substituter for the protocols in @var{recognised-uri-schemes}, diff --git a/nix/nix-daemon/guix-daemon.cc b/nix/nix-daemon/guix-daemon.cc index 30d0e5d11d..5545226a20 100644 --- a/nix/nix-daemon/guix-daemon.cc +++ b/nix/nix-daemon/guix-daemon.cc @@ -1,6 +1,7 @@ /* GNU Guix --- Functional package management for GNU Copyright (C) 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 Ludovic Courtès Copyright (C) 2006, 2010, 2012, 2014 Eelco Dolstra + Copyright (C) 2021 Maxime Devos This file is part of GNU Guix. @@ -90,6 +91,7 @@ builds derivations on behalf of its clients."); #define GUIX_OPT_MAX_SILENT_TIME 19 #define GUIX_OPT_LOG_COMPRESSION 20 #define GUIX_OPT_DISCOVER 21 +#define GUIX_OPT_SUBSTITUTE_METHODS 22 static const struct argp_option options[] = { @@ -114,6 +116,8 @@ static const struct argp_option options[] = n_("do not use substitutes") }, { "substitute-urls", GUIX_OPT_SUBSTITUTE_URLS, n_("URLS"), 0, n_("use URLS as the default list of substitute providers") }, + { "substitute-methods", GUIX_OPT_SUBSTITUTE_METHODS, n_("METHODS"), 0, + n_("use METHODS as the list of substitute methods") }, { "no-offload", GUIX_OPT_NO_BUILD_HOOK, 0, 0, n_("do not attempt to offload builds") }, { "no-build-hook", GUIX_OPT_NO_BUILD_HOOK, 0, @@ -263,6 +267,9 @@ parse_opt (int key, char *arg, struct argp_state *state) case GUIX_OPT_NO_SUBSTITUTES: settings.set ("build-use-substitutes", "false"); break; + case GUIX_OPT_SUBSTITUTE_METHODS: + settings.set ("substitute-methods", arg); + break; case GUIX_OPT_NO_BUILD_HOOK: settings.useBuildHook = false; break; -- 2.30.0