guix-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug#71038] [PATCH v2 1/2] guix: store: Enable specifying the available


From: Christopher Baines
Subject: [bug#71038] [PATCH v2 1/2] guix: store: Enable specifying the available builtin builders.
Date: Mon, 24 Jun 2024 14:43:45 +0100

To open-connection and port->connection.  This overrides the discovered
builtin builders that the daemon says it provides.

This is useful when you want to generate compatible derivations that can be
run with a daemon that potentially doesn't support builtin builders that the
daemon you're using to generate the derivations has.

I'm looking at this in particular because I want to use this in the data
service, since it provides substitutes for derivations, and since these can be
built on other machines, it's useful to control which builtin builders they
depend on.

* guix/store.scm (open-connection, port->connection): Accept
 #:assume-available-builtin-builders and use this instead of
%built-in-builders.

Fixes: <https://issues.guix.gnu.org/67250>.

Change-Id: I45d58ab93b6d276d280552858fc81ebc2b58828a
---
 guix/store.scm | 24 +++++++++++++++++-------
 1 file changed, 17 insertions(+), 7 deletions(-)

diff --git a/guix/store.scm b/guix/store.scm
index 58ddaa8d15..8c823a2185 100644
--- a/guix/store.scm
+++ b/guix/store.scm
@@ -571,7 +571,7 @@ (define* (connect-to-daemon uri #:key non-blocking?)
 
 (define* (open-connection #:optional (uri (%daemon-socket-uri))
                           #:key port (reserve-space? #t) cpu-affinity
-                          non-blocking?)
+                          non-blocking? assume-available-builtin-builders)
   "Connect to the daemon at URI (a string), or, if PORT is not #f, use it as
 the I/O port over which to communicate to a build daemon.
 
@@ -580,8 +580,10 @@ (define* (open-connection #:optional (uri 
(%daemon-socket-uri))
 should the disk become full.  When CPU-AFFINITY is true, it must be an integer
 corresponding to an OS-level CPU number to which the daemon's worker process
 for this connection will be pinned.  If NON-BLOCKING?, use a non-blocking
-socket when using the file, unix or guix URI schemes.  Return a server
-object."
+socket when using the file, unix or guix URI schemes.  If
+ASSUME-AVAILABLE-BUILTIN-BUILDERS is provided, it should be a list of strings
+and this will be used instead of the builtin builders provided by the build
+daemon.  Return a server object."
   (define (handshake-error)
     (raise (condition
             (&store-connection-error (file (or port uri))
@@ -616,7 +618,9 @@ (define* (open-connection #:optional (uri 
(%daemon-socket-uri))
           (when (>= (protocol-minor v) 11)
             (write-int (if reserve-space? 1 0) port))
           (letrec* ((built-in-builders
-                     (delay (%built-in-builders conn)))
+                     (if assume-available-builtin-builders
+                         (delay assume-available-builtin-builders)
+                         (delay (%built-in-builders conn))))
                     (caches
                      (make-vector
                       (atomic-box-ref %store-connection-caches)
@@ -635,9 +639,13 @@ (define* (open-connection #:optional (uri 
(%daemon-socket-uri))
             conn))))))
 
 (define* (port->connection port
-                           #:key (version %protocol-version))
+                           #:key (version %protocol-version)
+                           assume-available-builtin-builders)
   "Assimilate PORT, an input/output port, and return a connection to the
-daemon, assuming the given protocol VERSION.
+daemon, assuming the given protocol VERSION.  If
+ASSUME-AVAILABLE-BUILTIN-BUILDERS is provided, it should be a list of strings
+and this will be used instead of the builtin builders provided by the build
+daemon.
 
 Warning: this procedure assumes that the initial handshake with the daemon has
 already taken place on PORT and that we're just continuing on this established
@@ -654,7 +662,9 @@ (define* (port->connection port
                               (make-vector
                                (atomic-box-ref %store-connection-caches)
                                vlist-null)
-                              (delay (%built-in-builders connection))))
+                              (if assume-available-builtin-builders
+                                  (delay assume-available-builtin-builders)
+                                  (delay (%built-in-builders connection)))))
 
     connection))
 

base-commit: 018f2781d5aa301c156c81981f1fd3df56e438b9
-- 
2.45.1






reply via email to

[Prev in Thread] Current Thread [Next in Thread]