mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2024-12-24 05:18:07 -05:00
daemon: Client settings no longer override daemon settings.
Fixes <http://bugs.gnu.org/20217>. * nix/libstore/worker-protocol.hh (PROTOCOL_VERSION): Bump to 0x161. * nix/nix-daemon/nix-daemon.cc (performOp): "build-max-jobs", "build-max-silent-time", and "build-cores" are no longer read upfront; instead, read them from the key/value list at the end. * nix/nix-daemon/guix-daemon.cc (main): Explicitly set 'settings.maxBuildJobs'. * guix/store.scm (%protocol-version): Bump to #x161. (set-build-options): #:max-build-jobs, #:max-silent-time, and #:build-cores now default to #f. Adjust handshake to new protocol. * tests/store.scm ("build-cores"): New test. * tests/guix-daemon.sh: Add test for default "build-cores" value.
This commit is contained in:
parent
09cadc8e78
commit
deac976d3d
6 changed files with 95 additions and 18 deletions
|
@ -1,5 +1,5 @@
|
|||
;;; GNU Guix --- Functional package management for GNU
|
||||
;;; Copyright © 2012, 2013, 2014, 2015, 2016 Ludovic Courtès <ludo@gnu.org>
|
||||
;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017 Ludovic Courtès <ludo@gnu.org>
|
||||
;;;
|
||||
;;; This file is part of GNU Guix.
|
||||
;;;
|
||||
|
@ -138,7 +138,7 @@ (define-module (guix store)
|
|||
direct-store-path
|
||||
log-file))
|
||||
|
||||
(define %protocol-version #x10f)
|
||||
(define %protocol-version #x161)
|
||||
|
||||
(define %worker-magic-1 #x6e697863) ; "nixc"
|
||||
(define %worker-magic-2 #x6478696f) ; "dxio"
|
||||
|
@ -537,14 +537,14 @@ (define* (set-build-options server
|
|||
#:key keep-failed? keep-going? fallback?
|
||||
(verbosity 0)
|
||||
rounds ;number of build rounds
|
||||
(max-build-jobs 1)
|
||||
max-build-jobs
|
||||
timeout
|
||||
(max-silent-time 3600)
|
||||
max-silent-time
|
||||
(use-build-hook? #t)
|
||||
(build-verbosity 0)
|
||||
(log-type 0)
|
||||
(print-build-trace #t)
|
||||
(build-cores (current-processor-count))
|
||||
build-cores
|
||||
(use-substitutes? #t)
|
||||
|
||||
;; Client-provided substitute URLs. If it is #f,
|
||||
|
@ -570,21 +570,37 @@ (define socket
|
|||
...)))))
|
||||
(write-int (operation-id set-options) socket)
|
||||
(send (boolean keep-failed?) (boolean keep-going?)
|
||||
(boolean fallback?) (integer verbosity)
|
||||
(integer max-build-jobs) (integer max-silent-time))
|
||||
(boolean fallback?) (integer verbosity))
|
||||
(when (< (nix-server-minor-version server) #x61)
|
||||
(let ((max-build-jobs (or max-build-jobs 1))
|
||||
(max-silent-time (or max-silent-time 3600)))
|
||||
(send (integer max-build-jobs) (integer max-silent-time))))
|
||||
(when (>= (nix-server-minor-version server) 2)
|
||||
(send (boolean use-build-hook?)))
|
||||
(when (>= (nix-server-minor-version server) 4)
|
||||
(send (integer build-verbosity) (integer log-type)
|
||||
(boolean print-build-trace)))
|
||||
(when (>= (nix-server-minor-version server) 6)
|
||||
(send (integer build-cores)))
|
||||
(when (and (>= (nix-server-minor-version server) 6)
|
||||
(< (nix-server-minor-version server) #x61))
|
||||
(let ((build-cores (or build-cores (current-processor-count))))
|
||||
(send (integer build-cores))))
|
||||
(when (>= (nix-server-minor-version server) 10)
|
||||
(send (boolean use-substitutes?)))
|
||||
(when (>= (nix-server-minor-version server) 12)
|
||||
(let ((pairs `(,@(if timeout
|
||||
`(("build-timeout" . ,(number->string timeout)))
|
||||
'())
|
||||
,@(if max-silent-time
|
||||
`(("build-max-silent-time"
|
||||
. ,(number->string max-silent-time)))
|
||||
'())
|
||||
,@(if max-build-jobs
|
||||
`(("build-max-jobs"
|
||||
. ,(number->string max-build-jobs)))
|
||||
'())
|
||||
,@(if build-cores
|
||||
`(("build-cores" . ,(number->string build-cores)))
|
||||
'())
|
||||
,@(if substitute-urls
|
||||
`(("substitute-urls"
|
||||
. ,(string-join substitute-urls)))
|
||||
|
|
|
@ -6,7 +6,7 @@ namespace nix {
|
|||
#define WORKER_MAGIC_1 0x6e697863
|
||||
#define WORKER_MAGIC_2 0x6478696f
|
||||
|
||||
#define PROTOCOL_VERSION 0x160
|
||||
#define PROTOCOL_VERSION 0x161
|
||||
#define GET_PROTOCOL_MAJOR(x) ((x) & 0xff00)
|
||||
#define GET_PROTOCOL_MINOR(x) ((x) & 0x00ff)
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* GNU Guix --- Functional package management for GNU
|
||||
Copyright (C) 2012, 2013, 2014, 2015, 2016 Ludovic Courtès <ludo@gnu.org>
|
||||
Copyright (C) 2012, 2013, 2014, 2015, 2016, 2017 Ludovic Courtès <ludo@gnu.org>
|
||||
|
||||
This file is part of GNU Guix.
|
||||
|
||||
|
@ -301,8 +301,9 @@ main (int argc, char *argv[])
|
|||
/* Turn automatic deduplication on by default. */
|
||||
settings.autoOptimiseStore = true;
|
||||
|
||||
/* Default to using as many cores as possible. */
|
||||
/* Default to using as many cores as possible and one job at a time. */
|
||||
settings.buildCores = 0;
|
||||
settings.maxBuildJobs = 1;
|
||||
|
||||
argvSaved = argv;
|
||||
|
||||
|
|
|
@ -549,8 +549,12 @@ static void performOp(bool trusted, unsigned int clientVersion,
|
|||
settings.keepGoing = readInt(from) != 0;
|
||||
settings.set("build-fallback", readInt(from) ? "true" : "false");
|
||||
verbosity = (Verbosity) readInt(from);
|
||||
settings.set("build-max-jobs", std::to_string(readInt(from)));
|
||||
settings.set("build-max-silent-time", std::to_string(readInt(from)));
|
||||
|
||||
if (GET_PROTOCOL_MINOR(clientVersion) < 0x61) {
|
||||
settings.set("build-max-jobs", std::to_string(readInt(from)));
|
||||
settings.set("build-max-silent-time", std::to_string(readInt(from)));
|
||||
}
|
||||
|
||||
if (GET_PROTOCOL_MINOR(clientVersion) >= 2)
|
||||
settings.useBuildHook = readInt(from) != 0;
|
||||
if (GET_PROTOCOL_MINOR(clientVersion) >= 4) {
|
||||
|
@ -558,7 +562,8 @@ static void performOp(bool trusted, unsigned int clientVersion,
|
|||
logType = (LogType) readInt(from);
|
||||
settings.printBuildTrace = readInt(from) != 0;
|
||||
}
|
||||
if (GET_PROTOCOL_MINOR(clientVersion) >= 6)
|
||||
if (GET_PROTOCOL_MINOR(clientVersion) >= 6
|
||||
&& GET_PROTOCOL_MINOR(clientVersion) < 0x61)
|
||||
settings.set("build-cores", std::to_string(readInt(from)));
|
||||
if (GET_PROTOCOL_MINOR(clientVersion) >= 10)
|
||||
settings.set("build-use-substitutes", readInt(from) ? "true" : "false");
|
||||
|
@ -567,7 +572,10 @@ static void performOp(bool trusted, unsigned int clientVersion,
|
|||
for (unsigned int i = 0; i < n; i++) {
|
||||
string name = readString(from);
|
||||
string value = readString(from);
|
||||
if (name == "build-timeout" || name == "build-repeat" || name == "use-ssh-substituter")
|
||||
if (name == "build-timeout" || name == "build-max-silent-time"
|
||||
|| name == "build-max-jobs" || name == "build-cores"
|
||||
|| name == "build-repeat"
|
||||
|| name == "use-ssh-substituter")
|
||||
settings.set(name, value);
|
||||
else
|
||||
settings.set(trusted ? name : "untrusted-" + name, value);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# GNU Guix --- Functional package management for GNU
|
||||
# Copyright © 2012, 2014, 2015, 2016 Ludovic Courtès <ludo@gnu.org>
|
||||
# Copyright © 2012, 2014, 2015, 2016, 2017 Ludovic Courtès <ludo@gnu.org>
|
||||
#
|
||||
# This file is part of GNU Guix.
|
||||
#
|
||||
|
@ -118,3 +118,30 @@ guile -c "
|
|||
(clear-failed-paths store (list out))
|
||||
(null? (query-failed-paths store)))))))
|
||||
#:guile-for-build (%guile-for-build)) "
|
||||
|
||||
kill "$daemon_pid"
|
||||
|
||||
|
||||
# Make sure the daemon's default 'build-cores' setting is honored.
|
||||
|
||||
guix-daemon --listen="$socket" --disable-chroot --cores=42 &
|
||||
daemon_pid=$!
|
||||
|
||||
GUIX_DAEMON_SOCKET="$socket" \
|
||||
guile -c '
|
||||
(use-modules (guix) (gnu packages) (guix tests))
|
||||
|
||||
(with-store store
|
||||
(let* ((build (add-text-to-store store "build.sh"
|
||||
"echo $NIX_BUILD_CORES > $out"))
|
||||
(bash (add-to-store store "bash" #t "sha256"
|
||||
(search-bootstrap-binary "bash"
|
||||
(%current-system))))
|
||||
(drv (derivation store "the-thing" bash
|
||||
`("-e" ,build)
|
||||
#:inputs `((,bash) (,build))
|
||||
#:env-vars `(("x" . ,(random-text))))))
|
||||
(and (build-derivations store (list drv))
|
||||
(exit
|
||||
(= 42 (pk (call-with-input-file (derivation->output-path drv)
|
||||
read)))))))'
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
;;; GNU Guix --- Functional package management for GNU
|
||||
;;; Copyright © 2012, 2013, 2014, 2015, 2016 Ludovic Courtès <ludo@gnu.org>
|
||||
;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017 Ludovic Courtès <ludo@gnu.org>
|
||||
;;;
|
||||
;;; This file is part of GNU Guix.
|
||||
;;;
|
||||
|
@ -948,4 +948,29 @@ (define ref-hash
|
|||
(string=? (derivation-file-name d)
|
||||
(path-info-deriver (query-path-info %store o))))))
|
||||
|
||||
(test-equal "build-cores"
|
||||
(list 0 42)
|
||||
(with-store store
|
||||
(let* ((build (add-text-to-store store "build.sh"
|
||||
"echo $NIX_BUILD_CORES > $out"))
|
||||
(bash (add-to-store store "bash" #t "sha256"
|
||||
(search-bootstrap-binary "bash"
|
||||
(%current-system))))
|
||||
(drv1 (derivation store "the-thing" bash
|
||||
`("-e" ,build)
|
||||
#:inputs `((,bash) (,build))
|
||||
#:env-vars `(("x" . ,(random-text)))))
|
||||
(drv2 (derivation store "the-thing" bash
|
||||
`("-e" ,build)
|
||||
#:inputs `((,bash) (,build))
|
||||
#:env-vars `(("x" . ,(random-text))))))
|
||||
(and (build-derivations store (list drv1))
|
||||
(begin
|
||||
(set-build-options store #:build-cores 42)
|
||||
(build-derivations store (list drv2)))
|
||||
(list (call-with-input-file (derivation->output-path drv1)
|
||||
read)
|
||||
(call-with-input-file (derivation->output-path drv2)
|
||||
read))))))
|
||||
|
||||
(test-end "store")
|
||||
|
|
Loading…
Reference in a new issue