summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--guix/store.scm18
-rw-r--r--nix/libstore/worker-protocol.hh5
-rw-r--r--nix/nix-daemon/nix-daemon.cc17
-rw-r--r--tests/store.scm25
4 files changed, 58 insertions, 7 deletions
diff --git a/guix/store.scm b/guix/store.scm
index f8e77b2cd9d..97c4f32a5ba 100644
--- a/guix/store.scm
+++ b/guix/store.scm
@@ -1,5 +1,5 @@
1;;; GNU Guix --- Functional package management for GNU 1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2012-2022 Ludovic Courtès <ludo@gnu.org> 2;;; Copyright © 2012-2023 Ludovic Courtès <ludo@gnu.org>
3;;; Copyright © 2018 Jan Nieuwenhuizen <janneke@gnu.org> 3;;; Copyright © 2018 Jan Nieuwenhuizen <janneke@gnu.org>
4;;; Copyright © 2019, 2020 Mathieu Othacehe <m.othacehe@gmail.com> 4;;; Copyright © 2019, 2020 Mathieu Othacehe <m.othacehe@gmail.com>
5;;; Copyright © 2020 Florian Pelz <pelzflorian@pelzflorian.de> 5;;; Copyright © 2020 Florian Pelz <pelzflorian@pelzflorian.de>
@@ -145,6 +145,7 @@
145 path-info-nar-size 145 path-info-nar-size
146 146
147 built-in-builders 147 built-in-builders
148 substitute-urls
148 references 149 references
149 references/cached 150 references/cached
150 references* 151 references*
@@ -199,7 +200,7 @@
199 derivation-log-file 200 derivation-log-file
200 log-file)) 201 log-file))
201 202
202(define %protocol-version #x163) 203(define %protocol-version #x164)
203 204
204(define %worker-magic-1 #x6e697863) ; "nixc" 205(define %worker-magic-1 #x6e697863) ; "nixc"
205(define %worker-magic-2 #x6478696f) ; "dxio" 206(define %worker-magic-2 #x6478696f) ; "dxio"
@@ -253,7 +254,8 @@
253 (query-valid-derivers 33) 254 (query-valid-derivers 33)
254 (optimize-store 34) 255 (optimize-store 34)
255 (verify-store 35) 256 (verify-store 35)
256 (built-in-builders 80)) 257 (built-in-builders 80)
258 (substitute-urls 81))
257 259
258(define-enumerate-type hash-algo 260(define-enumerate-type hash-algo
259 ;; hash.hh 261 ;; hash.hh
@@ -1780,6 +1782,16 @@ The result is always the empty list unless the daemon was started with
1780This makes sense only when the daemon was started with '--cache-failures'." 1782This makes sense only when the daemon was started with '--cache-failures'."
1781 boolean) 1783 boolean)
1782 1784
1785(define substitute-urls
1786 (let ((urls (operation (substitute-urls)
1787 #f
1788 string-list)))
1789 (lambda (store)
1790 "Return the list of currently configured substitutes URLs for STORE, or
1791#f if the daemon is too old and does not implement this RPC."
1792 (and (>= (store-connection-version store) #x164)
1793 (urls store)))))
1794
1783 1795
1784;;; 1796;;;
1785;;; Per-connection caches. 1797;;; Per-connection caches.
diff --git a/nix/libstore/worker-protocol.hh b/nix/libstore/worker-protocol.hh
index ea67b10a5be..ef259db2a01 100644
--- a/nix/libstore/worker-protocol.hh
+++ b/nix/libstore/worker-protocol.hh
@@ -6,7 +6,7 @@ namespace nix {
6#define WORKER_MAGIC_1 0x6e697863 6#define WORKER_MAGIC_1 0x6e697863
7#define WORKER_MAGIC_2 0x6478696f 7#define WORKER_MAGIC_2 0x6478696f
8 8
9#define PROTOCOL_VERSION 0x163 9#define PROTOCOL_VERSION 0x164
10#define GET_PROTOCOL_MAJOR(x) ((x) & 0xff00) 10#define GET_PROTOCOL_MAJOR(x) ((x) & 0xff00)
11#define GET_PROTOCOL_MINOR(x) ((x) & 0x00ff) 11#define GET_PROTOCOL_MINOR(x) ((x) & 0x00ff)
12 12
@@ -44,7 +44,8 @@ typedef enum {
44 wopQueryValidDerivers = 33, 44 wopQueryValidDerivers = 33,
45 wopOptimiseStore = 34, 45 wopOptimiseStore = 34,
46 wopVerifyStore = 35, 46 wopVerifyStore = 35,
47 wopBuiltinBuilders = 80 47 wopBuiltinBuilders = 80,
48 wopSubstituteURLs = 81
48} WorkerOp; 49} WorkerOp;
49 50
50 51
diff --git a/nix/nix-daemon/nix-daemon.cc b/nix/nix-daemon/nix-daemon.cc
index 497de11a048..4cb05c802e0 100644
--- a/nix/nix-daemon/nix-daemon.cc
+++ b/nix/nix-daemon/nix-daemon.cc
@@ -736,6 +736,23 @@ static void performOp(bool trusted, unsigned int clientVersion,
736 break; 736 break;
737 } 737 }
738 738
739 case wopSubstituteURLs: {
740 startWork();
741 Strings urls;
742 if (settings.get("build-use-substitutes", std::string("false")) == "true") {
743 /* First check the client-provided substitute URLs, then those
744 passed to the daemon. */
745 auto str = settings.get("untrusted-substitute-urls", std::string(""));
746 if (str.empty()) {
747 str = settings.get("substitute-urls", std::string(""));
748 }
749 urls = tokenizeString<Strings>(str);
750 }
751 stopWork();
752 writeStrings(urls, to);
753 break;
754 }
755
739 default: 756 default:
740 throw Error(format("invalid operation %1%") % op); 757 throw Error(format("invalid operation %1%") % op);
741 } 758 }
diff --git a/tests/store.scm b/tests/store.scm
index 5df28adf0d2..45948f4f433 100644
--- a/tests/store.scm
+++ b/tests/store.scm
@@ -1,5 +1,5 @@
1;;; GNU Guix --- Functional package management for GNU 1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021 Ludovic Courtès <ludo@gnu.org> 2;;; Copyright © 2012-2021, 2023 Ludovic Courtès <ludo@gnu.org>
3;;; 3;;;
4;;; This file is part of GNU Guix. 4;;; This file is part of GNU Guix.
5;;; 5;;;
@@ -105,7 +105,28 @@
105 "/283gqy39v3g9dxjy26rynl0zls82fmcg-guile-2.0.7/bin/guile"))) 105 "/283gqy39v3g9dxjy26rynl0zls82fmcg-guile-2.0.7/bin/guile")))
106 (not (direct-store-path? (%store-prefix))))) 106 (not (direct-store-path? (%store-prefix)))))
107 107
108(test-skip (if %store 0 15)) 108(test-skip (if %store 0 18))
109
110(test-equal "substitute-urls, default"
111 (list (getenv "GUIX_BINARY_SUBSTITUTE_URL"))
112 (with-store store
113 (set-build-options store #:use-substitutes? #t)
114 (substitute-urls store)))
115
116(test-equal "substitute-urls, client-specified URLs"
117 '("http://substitutes.example.org"
118 "http://other.example.org")
119 (with-store store
120 (set-build-options store #:use-substitutes? #t
121 #:substitute-urls '("http://substitutes.example.org"
122 "http://other.example.org"))
123 (substitute-urls store)))
124
125(test-equal "substitute-urls, disabled"
126 '()
127 (with-store store
128 (set-build-options store #:use-substitutes? #f)
129 (substitute-urls store)))
109 130
110(test-equal "profiles/per-user exists and is not writable" 131(test-equal "profiles/per-user exists and is not writable"
111 #o755 132 #o755