From: "Ludovic Courtès" <ludo@gnu.org>
To: 67072@debbugs.gnu.org
Cc: "Ludovic Courtès" <ludo@gnu.org>,
"Christopher Baines" <guix@cbaines.net>,
"Josselin Poiret" <dev@jpoiret.xyz>,
"Ludovic Courtès" <ludo@gnu.org>,
"Mathieu Othacehe" <othacehe@gnu.org>,
"Ricardo Wurmus" <rekado@elephly.net>,
"Simon Tournier" <zimon.toutoune@gmail.com>,
"Tobias Geerinckx-Rice" <me@tobias.gr>
Subject: [bug#67072] [PATCH v2 1/4] daemon: Implement ‘substitute-urls’ RPC.
Date: Mon, 4 Dec 2023 15:15:42 +0100 [thread overview]
Message-ID: <22d2093841b549484a8c5c03207ec3c34a01f7e0.1701699075.git.ludo@gnu.org> (raw)
In-Reply-To: <875y1gj47u.fsf@gnu.org>
* nix/libstore/worker-protocol.hh (PROTOCOL_VERSION): Bump.
(WorkerOp): Add ‘wopSubstituteURLs’.
* nix/nix-daemon/nix-daemon.cc (performOp): Implement it.
* guix/store.scm (%protocol-version): Bump.
(operation-id): Add ‘substitute-urls’.
(substitute-urls): New procedure.
* tests/store.scm ("substitute-urls, default")
("substitute-urls, client-specified URLs")
("substitute-urls, disabled"): New tests.
Change-Id: I2c0119500c3a1eecfa5ebf32463ffb0f173161de
---
guix/store.scm | 18 +++++++++++++++---
nix/libstore/worker-protocol.hh | 5 +++--
nix/nix-daemon/nix-daemon.cc | 17 +++++++++++++++++
tests/store.scm | 25 +++++++++++++++++++++++--
4 files changed, 58 insertions(+), 7 deletions(-)
diff --git a/guix/store.scm b/guix/store.scm
index f8e77b2cd9..97c4f32a5b 100644
--- a/guix/store.scm
+++ b/guix/store.scm
@@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2012-2022 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2012-2023 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2018 Jan Nieuwenhuizen <janneke@gnu.org>
;;; Copyright © 2019, 2020 Mathieu Othacehe <m.othacehe@gmail.com>
;;; Copyright © 2020 Florian Pelz <pelzflorian@pelzflorian.de>
@@ -145,6 +145,7 @@ (define-module (guix store)
path-info-nar-size
built-in-builders
+ substitute-urls
references
references/cached
references*
@@ -199,7 +200,7 @@ (define-module (guix store)
derivation-log-file
log-file))
-(define %protocol-version #x163)
+(define %protocol-version #x164)
(define %worker-magic-1 #x6e697863) ; "nixc"
(define %worker-magic-2 #x6478696f) ; "dxio"
@@ -253,7 +254,8 @@ (define-enumerate-type operation-id
(query-valid-derivers 33)
(optimize-store 34)
(verify-store 35)
- (built-in-builders 80))
+ (built-in-builders 80)
+ (substitute-urls 81))
(define-enumerate-type hash-algo
;; hash.hh
@@ -1780,6 +1782,16 @@ (define-operation (clear-failed-paths (store-path-list items))
This makes sense only when the daemon was started with '--cache-failures'."
boolean)
+(define substitute-urls
+ (let ((urls (operation (substitute-urls)
+ #f
+ string-list)))
+ (lambda (store)
+ "Return the list of currently configured substitutes URLs for STORE, or
+#f if the daemon is too old and does not implement this RPC."
+ (and (>= (store-connection-version store) #x164)
+ (urls store)))))
+
\f
;;;
;;; Per-connection caches.
diff --git a/nix/libstore/worker-protocol.hh b/nix/libstore/worker-protocol.hh
index ea67b10a5b..ef259db2a0 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 0x163
+#define PROTOCOL_VERSION 0x164
#define GET_PROTOCOL_MAJOR(x) ((x) & 0xff00)
#define GET_PROTOCOL_MINOR(x) ((x) & 0x00ff)
@@ -44,7 +44,8 @@ typedef enum {
wopQueryValidDerivers = 33,
wopOptimiseStore = 34,
wopVerifyStore = 35,
- wopBuiltinBuilders = 80
+ wopBuiltinBuilders = 80,
+ wopSubstituteURLs = 81
} WorkerOp;
diff --git a/nix/nix-daemon/nix-daemon.cc b/nix/nix-daemon/nix-daemon.cc
index 497de11a04..4cb05c802e 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,
break;
}
+ case wopSubstituteURLs: {
+ startWork();
+ Strings urls;
+ if (settings.get("build-use-substitutes", std::string("false")) == "true") {
+ /* First check the client-provided substitute URLs, then those
+ passed to the daemon. */
+ auto str = settings.get("untrusted-substitute-urls", std::string(""));
+ if (str.empty()) {
+ str = settings.get("substitute-urls", std::string(""));
+ }
+ urls = tokenizeString<Strings>(str);
+ }
+ stopWork();
+ writeStrings(urls, to);
+ break;
+ }
+
default:
throw Error(format("invalid operation %1%") % op);
}
diff --git a/tests/store.scm b/tests/store.scm
index 5df28adf0d..45948f4f43 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, 2017, 2018, 2019, 2020, 2021 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2012-2021, 2023 Ludovic Courtès <ludo@gnu.org>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -105,7 +105,28 @@ (define %shell
"/283gqy39v3g9dxjy26rynl0zls82fmcg-guile-2.0.7/bin/guile")))
(not (direct-store-path? (%store-prefix)))))
-(test-skip (if %store 0 15))
+(test-skip (if %store 0 18))
+
+(test-equal "substitute-urls, default"
+ (list (getenv "GUIX_BINARY_SUBSTITUTE_URL"))
+ (with-store store
+ (set-build-options store #:use-substitutes? #t)
+ (substitute-urls store)))
+
+(test-equal "substitute-urls, client-specified URLs"
+ '("http://substitutes.example.org"
+ "http://other.example.org")
+ (with-store store
+ (set-build-options store #:use-substitutes? #t
+ #:substitute-urls '("http://substitutes.example.org"
+ "http://other.example.org"))
+ (substitute-urls store)))
+
+(test-equal "substitute-urls, disabled"
+ '()
+ (with-store store
+ (set-build-options store #:use-substitutes? #f)
+ (substitute-urls store)))
(test-equal "profiles/per-user exists and is not writable"
#o755
--
2.41.0
next prev parent reply other threads:[~2023-12-04 14:17 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-11 11:03 [bug#67072] [PATCH 0/4] Helping diagnose substitute setup issues Ludovic Courtès
2023-11-11 11:06 ` [bug#67072] [PATCH 1/4] daemon: Implement ‘substitute-urls’ RPC Ludovic Courtès
2023-11-28 12:09 ` Simon Tournier
2023-12-02 10:13 ` Ludovic Courtès
2023-12-02 13:16 ` Simon Tournier
2023-11-11 11:06 ` [bug#67072] [PATCH 2/4] challenge: Use the same substitute URLs as guix-daemon Ludovic Courtès
2023-11-11 11:06 ` [bug#67072] [PATCH 3/4] weather: " Ludovic Courtès
2023-11-11 11:06 ` [bug#67072] [PATCH 4/4] weather: Report unauthorized substitute servers Ludovic Courtès
2023-11-28 13:14 ` Simon Tournier
2023-12-02 10:20 ` Ludovic Courtès
2023-12-02 13:31 ` Simon Tournier
2023-12-04 14:15 ` [bug#67072] [PATCH v2 0/4] Helping diagnose substitute setup issues Ludovic Courtès
2023-12-11 22:52 ` bug#67072: " Ludovic Courtès
2023-12-04 14:15 ` Ludovic Courtès [this message]
2023-12-04 14:15 ` [bug#67072] [PATCH v2 2/4] challenge: Use the same substitute URLs as guix-daemon Ludovic Courtès
2023-12-04 14:15 ` [bug#67072] [PATCH v2 3/4] weather: " Ludovic Courtès
2023-12-04 14:15 ` [bug#67072] [PATCH v2 4/4] weather: Report unauthorized substitute servers Ludovic Courtès
2023-11-27 17:21 ` [bug#67072] [PATCH 0/4] Helping diagnose substitute setup issues Ludovic Courtès
2023-11-28 13:17 ` Simon Tournier
2023-11-30 10:11 ` Emmanuel Agullo
2023-11-30 10:28 ` Ludovic Courtès
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=22d2093841b549484a8c5c03207ec3c34a01f7e0.1701699075.git.ludo@gnu.org \
--to=ludo@gnu.org \
--cc=67072@debbugs.gnu.org \
--cc=dev@jpoiret.xyz \
--cc=guix@cbaines.net \
--cc=me@tobias.gr \
--cc=othacehe@gnu.org \
--cc=rekado@elephly.net \
--cc=zimon.toutoune@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.