diff options
author | Ludovic Courtès <ludo@gnu.org> | 2014-10-09 13:25:41 +0200 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2014-10-09 23:51:19 +0200 |
commit | 9176607ec4cffb85b46e71af49bbc8a330aec5c3 (patch) | |
tree | fff85fb1ca12965acaa29f8aaa650237f2b2f56d /guix/scripts | |
parent | 74c7af9fb83bd4803b0f2cad4e6439bfad75edf0 (diff) |
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.
Diffstat (limited to 'guix/scripts')
-rwxr-xr-x | guix/scripts/substitute-binary.scm | 44 |
1 files changed, 40 insertions, 4 deletions
diff --git a/guix/scripts/substitute-binary.scm b/guix/scripts/substitute-binary.scm index ec7596efb6..7a286426a1 100755 --- a/guix/scripts/substitute-binary.scm +++ b/guix/scripts/substitute-binary.scm @@ -528,10 +528,6 @@ PORT. REPORT-PROGRESS is a two-argument procedure such as that returned by (_ "(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 @@ Internal tool to substitute a pre-built binary to a local build.\n")) (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) |