mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2024-12-24 05:18:07 -05:00
daemon: Add '--substitute-urls' option.
* nix/nix-daemon/guix-daemon.cc (GUIX_OPT_SUBSTITUTE_URLS): New macro. (GUIX_OPT_NO_BUILD_HOOK, GUIX_OPT_GC_KEEP_OUTPUTS, GUIX_OPT_GC_KEEP_DERIVATIONS): Renumber. (options): Add '--substitute-urls'. (parse_opt): Honor it. (main): Add 'settings.set' call for the default "substitute-urls" value. * guix/scripts/substitute-binary.scm (daemon-options, find-daemon-option): New procedures. (%cache-url): Define based on the "substitute-urls" daemon option. * doc/guix.texi (Invoking guix-daemon): Document '--substitute-urls'. (Substitutes): Mention it.
This commit is contained in:
parent
74c7af9fb8
commit
9176607ec4
3 changed files with 64 additions and 8 deletions
|
@ -453,6 +453,14 @@ When the daemon runs with @code{--no-substitutes}, clients can still
|
|||
explicitly enable substitution @i{via} the @code{set-build-options}
|
||||
remote procedure call (@pxref{The Store}).
|
||||
|
||||
@item --substitute-urls=@var{urls}
|
||||
Consider @var{urls} the default whitespace-separated list of substitute
|
||||
source URLs. When this option is omitted, @code{http://hydra.gnu.org}
|
||||
is used.
|
||||
|
||||
This means that substitutes may be downloaded from @var{urls}, as long
|
||||
as they are signed by a trusted signature (@pxref{Substitutes}).
|
||||
|
||||
@cindex build hook
|
||||
@item --no-build-hook
|
||||
Do not use the @dfn{build hook}.
|
||||
|
@ -981,7 +989,10 @@ also result from derivation builds, can be available as substitutes.
|
|||
|
||||
The @code{hydra.gnu.org} server is a front-end to a build farm that
|
||||
builds packages from the GNU distribution continuously for some
|
||||
architectures, and makes them available as substitutes.
|
||||
architectures, and makes them available as substitutes. This is the
|
||||
default source of substitutes; it can be overridden by passing
|
||||
@command{guix-daemon} the @code{--substitute-urls} option
|
||||
(@pxref{Invoking guix-daemon}).
|
||||
|
||||
@cindex security
|
||||
@cindex digital signatures
|
||||
|
|
|
@ -528,10 +528,6 @@ (define (read! bv start count)
|
|||
(_ "(Please consider upgrading Guile to get proper progress report.)~%"))
|
||||
port)))
|
||||
|
||||
(define %cache-url
|
||||
(or (getenv "GUIX_BINARY_SUBSTITUTE_URL")
|
||||
"http://hydra.gnu.org"))
|
||||
|
||||
(define-syntax with-networking
|
||||
(syntax-rules ()
|
||||
"Catch DNS lookup errors and gracefully exit."
|
||||
|
@ -604,6 +600,46 @@ (define (singleton? acl)
|
|||
(warning (_ "ACL for archive imports seems to be uninitialized, \
|
||||
substitutes may be unavailable\n")))))
|
||||
|
||||
(define (daemon-options)
|
||||
"Return a list of name/value pairs denoting build daemon options."
|
||||
(define %not-newline
|
||||
(char-set-complement (char-set #\newline)))
|
||||
|
||||
(match (getenv "_NIX_OPTIONS")
|
||||
(#f ;should not happen when called by the daemon
|
||||
'())
|
||||
(newline-separated
|
||||
;; Here we get something of the form "OPTION1=VALUE1\nOPTION2=VALUE2\n".
|
||||
(filter-map (lambda (option=value)
|
||||
(match (string-index option=value #\=)
|
||||
(#f ;invalid option setting
|
||||
#f)
|
||||
(equal-sign
|
||||
(cons (string-take option=value equal-sign)
|
||||
(string-drop option=value (+ 1 equal-sign))))))
|
||||
(string-tokenize newline-separated %not-newline)))))
|
||||
|
||||
(define (find-daemon-option option)
|
||||
"Return the value of build daemon option OPTION, or #f if it could not be
|
||||
found."
|
||||
(assoc-ref (daemon-options) option))
|
||||
|
||||
(define %cache-url
|
||||
(or (getenv "GUIX_BINARY_SUBSTITUTE_URL")
|
||||
(match (and=> (find-daemon-option "substitute-urls")
|
||||
string-tokenize)
|
||||
((url)
|
||||
url)
|
||||
((head tail ..1)
|
||||
;; Currently we don't handle multiple substitute URLs.
|
||||
(warning (_ "these substitute URLs will not be used:~{ ~a~}~%")
|
||||
tail)
|
||||
head)
|
||||
(#f
|
||||
;; This can only happen when this script is not invoked by the
|
||||
;; daemon.
|
||||
"http://hydra.gnu.org"))))
|
||||
|
||||
(define (guix-substitute-binary . args)
|
||||
"Implement the build daemon's substituter protocol."
|
||||
(mkdir-p %narinfo-cache-directory)
|
||||
|
|
|
@ -68,9 +68,10 @@ builds derivations on behalf of its clients.";
|
|||
#define GUIX_OPT_CHROOT_DIR 10
|
||||
#define GUIX_OPT_LISTEN 11
|
||||
#define GUIX_OPT_NO_SUBSTITUTES 12
|
||||
#define GUIX_OPT_NO_BUILD_HOOK 13
|
||||
#define GUIX_OPT_GC_KEEP_OUTPUTS 14
|
||||
#define GUIX_OPT_GC_KEEP_DERIVATIONS 15
|
||||
#define GUIX_OPT_SUBSTITUTE_URLS 13
|
||||
#define GUIX_OPT_NO_BUILD_HOOK 14
|
||||
#define GUIX_OPT_GC_KEEP_OUTPUTS 15
|
||||
#define GUIX_OPT_GC_KEEP_DERIVATIONS 16
|
||||
|
||||
static const struct argp_option options[] =
|
||||
{
|
||||
|
@ -98,6 +99,8 @@ static const struct argp_option options[] =
|
|||
"Perform builds as a user of GROUP" },
|
||||
{ "no-substitutes", GUIX_OPT_NO_SUBSTITUTES, 0, 0,
|
||||
"Do not use substitutes" },
|
||||
{ "substitute-urls", GUIX_OPT_SUBSTITUTE_URLS, "URLS", 0,
|
||||
"Use URLS as the default list of substitute providers" },
|
||||
{ "no-build-hook", GUIX_OPT_NO_BUILD_HOOK, 0, 0,
|
||||
"Do not use the 'build hook'" },
|
||||
{ "cache-failures", GUIX_OPT_CACHE_FAILURES, 0, 0,
|
||||
|
@ -192,6 +195,9 @@ parse_opt (int key, char *arg, struct argp_state *state)
|
|||
exit (EXIT_FAILURE);
|
||||
}
|
||||
break;
|
||||
case GUIX_OPT_SUBSTITUTE_URLS:
|
||||
settings.set ("substitute-urls", arg);
|
||||
break;
|
||||
case GUIX_OPT_NO_SUBSTITUTES:
|
||||
settings.set ("build-use-substitutes", "false");
|
||||
break;
|
||||
|
@ -280,6 +286,9 @@ main (int argc, char *argv[])
|
|||
settings.substituters.clear ();
|
||||
settings.set ("build-use-substitutes", "true");
|
||||
|
||||
/* Use our substitute server by default. */
|
||||
settings.set ("substitute-urls", "http://hydra.gnu.org");
|
||||
|
||||
#ifdef HAVE_DAEMON_OFFLOAD_HOOK
|
||||
/* Use our build hook for distributed builds by default. */
|
||||
settings.useBuildHook = true;
|
||||
|
|
Loading…
Reference in a new issue