diff options
-rw-r--r-- | guix/store.scm | 34 | ||||
-rw-r--r-- | nix/libstore/worker-protocol.hh | 2 | ||||
-rw-r--r-- | nix/nix-daemon/guix-daemon.cc | 5 | ||||
-rw-r--r-- | nix/nix-daemon/nix-daemon.cc | 16 | ||||
-rw-r--r-- | tests/guix-daemon.sh | 29 | ||||
-rw-r--r-- | tests/store.scm | 27 |
6 files changed, 95 insertions, 18 deletions
diff --git a/guix/store.scm b/guix/store.scm index 49549d0771..7152a5556a 100644 --- a/guix/store.scm +++ b/guix/store.scm @@ -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 @@ 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 @@ encoding conversion errors." #: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 @@ encoding conversion errors." ...))))) (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))) diff --git a/nix/libstore/worker-protocol.hh b/nix/libstore/worker-protocol.hh index bdeaca2e3a..efe9eadf23 100644 --- a/nix/libstore/worker-protocol.hh +++ b/nix/libstore/worker-protocol.hh @@ -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) diff --git a/nix/nix-daemon/guix-daemon.cc b/nix/nix-daemon/guix-daemon.cc index d5d33a587a..aa47a290d2 100644 --- a/nix/nix-daemon/guix-daemon.cc +++ b/nix/nix-daemon/guix-daemon.cc @@ -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; diff --git a/nix/nix-daemon/nix-daemon.cc b/nix/nix-daemon/nix-daemon.cc index 47b67d5863..79580ffb48 100644 --- a/nix/nix-daemon/nix-daemon.cc +++ b/nix/nix-daemon/nix-daemon.cc @@ -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); diff --git a/tests/guix-daemon.sh b/tests/guix-daemon.sh index 7122eed0e6..fde49e25a2 100644 --- a/tests/guix-daemon.sh +++ b/tests/guix-daemon.sh @@ -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)))))))' diff --git a/tests/store.scm b/tests/store.scm index 123ea8a787..983766d862 100644 --- a/tests/store.scm +++ b/tests/store.scm @@ -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 @@ (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") |