From patchwork Sat May 18 13:19:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christopher Baines X-Patchwork-Id: 64592 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id EA07227BBE9; Sat, 18 May 2024 14:20:24 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 60F5327BBE2 for ; Sat, 18 May 2024 14:20:24 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s8Jyp-0002Hu-62; Sat, 18 May 2024 09:20:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s8Jym-0002Hb-23 for guix-patches@gnu.org; Sat, 18 May 2024 09:20:04 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s8Jyj-0005Mb-OA; Sat, 18 May 2024 09:20:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1s8Jyk-0006AM-95; Sat, 18 May 2024 09:20:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#71038] [PATCH 1/2] guix: store: Enable specifying the available builtin builders. References: <87y187b6xv.fsf@cbaines.net> In-Reply-To: <87y187b6xv.fsf@cbaines.net> Resent-From: Christopher Baines Original-Sender: "Debbugs-submit" Resent-CC: guix@cbaines.net, dev@jpoiret.xyz, ludo@gnu.org, othacehe@gnu.org, rekado@elephly.net, zimon.toutoune@gmail.com, me@tobias.gr, guix-patches@gnu.org Resent-Date: Sat, 18 May 2024 13:20:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 71038 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 71038@debbugs.gnu.org Cc: Christopher Baines , Josselin Poiret , Ludovic =?utf-8?q?Court=C3=A8s?= , Mathieu Othacehe , Ricardo Wurmus , Simon Tournier , Tobias Geerinckx-Rice X-Debbugs-Original-Xcc: Christopher Baines , Josselin Poiret , Ludovic =?utf-8?q?Court=C3=A8s?= , Mathieu Othacehe , Ricardo Wurmus , Simon Tournier , Tobias Geerinckx-Rice Received: via spool by 71038-submit@debbugs.gnu.org id=B71038.171603838423679 (code B ref 71038); Sat, 18 May 2024 13:20:02 +0000 Received: (at 71038) by debbugs.gnu.org; 18 May 2024 13:19:44 +0000 Received: from localhost ([127.0.0.1]:33447 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s8JyR-00069r-IK for submit@debbugs.gnu.org; Sat, 18 May 2024 09:19:43 -0400 Received: from mira.cbaines.net ([212.71.252.8]:43556) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s8JyQ-00069f-6r for 71038@debbugs.gnu.org; Sat, 18 May 2024 09:19:42 -0400 Received: from localhost (unknown [89.207.171.92]) by mira.cbaines.net (Postfix) with ESMTPSA id 490D227BBE2 for <71038@debbugs.gnu.org>; Sat, 18 May 2024 14:19:36 +0100 (BST) Received: from localhost (localhost [local]) by localhost (OpenSMTPD) with ESMTPA id c02c102f for <71038@debbugs.gnu.org>; Sat, 18 May 2024 13:19:35 +0000 (UTC) From: Christopher Baines Date: Sat, 18 May 2024 14:19:34 +0100 Message-ID: <6b9c634c024b6fd7a50d3b82edc244676a8ca8e8.1716038375.git.mail@cbaines.net> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches 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: . Change-Id: I45d58ab93b6d276d280552858fc81ebc2b58828a --- guix/store.scm | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) base-commit: 0846eaecd45783bf40e8dc67b0c16f71068524b7 diff --git a/guix/store.scm b/guix/store.scm index 58ddaa8d15..0c734cdca7 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. @@ -616,7 +616,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,7 +637,8 @@ (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. @@ -654,7 +657,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)) From patchwork Sat May 18 13:19:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christopher Baines X-Patchwork-Id: 64591 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 9DC2D27BBEA; Sat, 18 May 2024 14:20:20 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 6C9BA27BBE2 for ; Sat, 18 May 2024 14:20:19 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s8Jyq-0002I5-Uj; Sat, 18 May 2024 09:20:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s8Jym-0002Hc-2t for guix-patches@gnu.org; Sat, 18 May 2024 09:20:04 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s8Jyj-0005KH-1r; Sat, 18 May 2024 09:20:01 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1s8Jyk-0006AS-LD; Sat, 18 May 2024 09:20:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#71038] [PATCH 2/2] guix: channels: Enable specifiying available builtin builders. Resent-From: Christopher Baines Original-Sender: "Debbugs-submit" Resent-CC: guix@cbaines.net, dev@jpoiret.xyz, ludo@gnu.org, othacehe@gnu.org, rekado@elephly.net, zimon.toutoune@gmail.com, me@tobias.gr, guix-patches@gnu.org Resent-Date: Sat, 18 May 2024 13:20:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 71038 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 71038@debbugs.gnu.org Cc: Christopher Baines , Josselin Poiret , Ludovic =?utf-8?q?Court=C3=A8s?= , Mathieu Othacehe , Ricardo Wurmus , Simon Tournier , Tobias Geerinckx-Rice X-Debbugs-Original-Xcc: Christopher Baines , Josselin Poiret , Ludovic =?utf-8?q?Court=C3=A8s?= , Mathieu Othacehe , Ricardo Wurmus , Simon Tournier , Tobias Geerinckx-Rice Received: via spool by 71038-submit@debbugs.gnu.org id=B71038.171603838823686 (code B ref 71038); Sat, 18 May 2024 13:20:02 +0000 Received: (at 71038) by debbugs.gnu.org; 18 May 2024 13:19:48 +0000 Received: from localhost ([127.0.0.1]:33449 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s8JyV-00069y-Um for submit@debbugs.gnu.org; Sat, 18 May 2024 09:19:48 -0400 Received: from mira.cbaines.net ([212.71.252.8]:43558) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s8JyQ-00069g-OB for 71038@debbugs.gnu.org; Sat, 18 May 2024 09:19:43 -0400 Received: from localhost (unknown [89.207.171.92]) by mira.cbaines.net (Postfix) with ESMTPSA id 7257B27BBE9 for <71038@debbugs.gnu.org>; Sat, 18 May 2024 14:19:38 +0100 (BST) Received: from localhost (localhost [local]) by localhost (OpenSMTPD) with ESMTPA id ba9ae70a for <71038@debbugs.gnu.org>; Sat, 18 May 2024 13:19:36 +0000 (UTC) From: Christopher Baines Date: Sat, 18 May 2024 14:19:35 +0100 Message-ID: <3724435f5b2e86be53ffba5bffcbfdf493b48e5c.1716038375.git.mail@cbaines.net> X-Mailer: git-send-email 2.41.0 In-Reply-To: <6b9c634c024b6fd7a50d3b82edc244676a8ca8e8.1716038375.git.mail@cbaines.net> References: <6b9c634c024b6fd7a50d3b82edc244676a8ca8e8.1716038375.git.mail@cbaines.net> MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches When computing channel instance derivations. 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. Fixes: . * build-aux/build-self.scm (build-program): Accept #:assume-available-builtin-builders and pass along to port->connection or open-connection as approriate. (build): Accept and pass on #:assume-available-builtin-builders. * guix/channels.scm (build-from-source, build-channel-instance, channel-instance-derivations, channel-instances->manifest, channel-instances->derivation): Accept and pass on #:assume-available-builtin-builders. Change-Id: I315c990de66c6f7dca25a859165a5568abe385ea --- build-aux/build-self.scm | 28 ++++++++++++++++++-------- guix/channels.scm | 43 +++++++++++++++++++++++++++++----------- 2 files changed, 51 insertions(+), 20 deletions(-) diff --git a/build-aux/build-self.scm b/build-aux/build-self.scm index 02822a2ee8..7afb13c1e4 100644 --- a/build-aux/build-self.scm +++ b/build-aux/build-self.scm @@ -241,7 +241,8 @@ (define guile-gcrypt (define* (build-program source version #:optional (guile-version (effective-version)) - #:key (pull-version 0) (channel-metadata #f)) + #:key (pull-version 0) (channel-metadata #f) + assume-available-builtin-builders) "Return a program that computes the derivation to build Guix from SOURCE." (define select? ;; Select every module but (guix config) and non-Guix modules. @@ -331,11 +332,20 @@ (define* (build-program source version ;; case, attempt to open a new connection. (let* ((proto (string->number protocol-version)) (store (if (integer? proto) - (port->connection (duplicate-port - (current-input-port) - "w+0") - #:version proto) - (open-connection))) + (port->connection + (duplicate-port + (current-input-port) + "w+0") + #:version proto + #$@(if assume-available-builtin-builders + #~(#:assume-available-builtin-builders + '(#$@assume-available-builtin-builders)) + '())) + (open-connection + #$@(if assume-available-builtin-builders + #~(#:assume-available-builtin-builders + '(#$@assume-available-builtin-builders)) + '())))) (sock (socket AF_UNIX SOCK_STREAM 0))) ;; Connect to BUILD-OUTPUT and send it the raw ;; build output. @@ -406,7 +416,7 @@ (define* (build source (guile-version (if (> pull-version 0) "3.0" (effective-version))) - + assume-available-builtin-builders #:allow-other-keys #:rest rest) "Return a derivation that unpacks SOURCE into STORE and compiles Scheme @@ -415,7 +425,9 @@ (define* (build source ;; SOURCE. (mlet %store-monad ((build (build-program source version guile-version #:channel-metadata channel-metadata - #:pull-version pull-version)) + #:pull-version pull-version + #:assume-available-builtin-builders + assume-available-builtin-builders)) (system (if system (return system) (current-system))) (home -> (getenv "HOME")) diff --git a/guix/channels.scm b/guix/channels.scm index 0d7bc541cc..6469d08bb9 100644 --- a/guix/channels.scm +++ b/guix/channels.scm @@ -704,7 +704,8 @@ (define (with-trivial-build-handler mvalue) store)))) (define* (build-from-source instance - #:key core verbose? (dependencies '()) system) + #:key core verbose? (dependencies '()) system + assume-available-builtin-builders) "Return a derivation to build Guix from INSTANCE, using the self-build script contained therein. When CORE is true, build package modules under SOURCE using CORE, an instance of Guix. By default, build for the current @@ -750,20 +751,25 @@ (define* (build-from-source instance #:verbose? verbose? #:version commit #:system system #:channel-metadata (channel-instance->sexp instance) - #:pull-version %pull-version)))) + #:pull-version %pull-version + #:assume-available-builtin-builders + assume-available-builtin-builders)))) ;; Build a set of modules that extend Guix using the standard method. (standard-module-derivation name source core dependencies))) (define* (build-channel-instance instance system - #:optional core (dependencies '())) + #:optional core (dependencies '()) + #:key assume-available-builtin-builders) "Return, as a monadic value, the derivation for INSTANCE, a channel instance, for SYSTEM. DEPENDENCIES is a list of extensions providing Guile modules that INSTANCE depends on." (build-from-source instance #:core core #:dependencies dependencies - #:system system)) + #:system system + #:assume-available-builtin-builders + assume-available-builtin-builders)) (define (resolve-dependencies instances) "Return a procedure that, given one of the elements of INSTANCES, returns @@ -793,7 +799,8 @@ (define (resolve-dependencies instances) (lambda (instance) (vhash-foldq* cons '() instance edges))) -(define* (channel-instance-derivations instances #:key system) +(define* (channel-instance-derivations instances #:key system + assume-available-builtin-builders) "Return the list of derivations to build INSTANCES, in the same order as INSTANCES. Build for the current system by default, or SYSTEM if specified." (define core-instance @@ -809,11 +816,15 @@ (define* (channel-instance-derivations instances #:key system) (define (instance->derivation instance) (mlet %store-monad ((system (if system (return system) (current-system)))) (mcached (if (eq? instance core-instance) - (build-channel-instance instance system) + (build-channel-instance instance system + #:assume-available-builtin-builders + assume-available-builtin-builders) (mlet %store-monad ((core (instance->derivation core-instance)) (deps (mapm %store-monad instance->derivation (edges instance)))) - (build-channel-instance instance system core deps))) + (build-channel-instance instance system core deps + #:assume-available-builtin-builders + assume-available-builtin-builders))) instance system))) @@ -915,7 +926,8 @@ (define (channel-instance->sexp instance) intro)))))) '())))) -(define* (channel-instances->manifest instances #:key system) +(define* (channel-instances->manifest instances #:key system + assume-available-builtin-builders) "Return a profile manifest with entries for all of INSTANCES, a list of channel instances. By default, build for the current system, or SYSTEM if specified." @@ -934,8 +946,11 @@ (define* (channel-instances->manifest instances #:key system) (properties `((source ,(channel-instance->sexp instance))))))) - (mlet* %store-monad ((derivations (channel-instance-derivations instances - #:system system)) + (mlet* %store-monad ((derivations (channel-instance-derivations + instances + #:system system + #:assume-available-builtin-builders + assume-available-builtin-builders)) (entries -> (map instance->entry instances derivations))) (return (manifest entries)))) @@ -990,10 +1005,14 @@ (define %channel-profile-hooks ;; The default channel profile hooks. (cons package-cache-file %default-profile-hooks)) -(define (channel-instances->derivation instances) +(define* (channel-instances->derivation instances + #:key assume-available-builtin-builders) "Return the derivation of the profile containing INSTANCES, a list of channel instances." - (mlet %store-monad ((manifest (channel-instances->manifest instances))) + (mlet %store-monad ((manifest (channel-instances->manifest + instances + #:assume-available-builtin-builders + assume-available-builtin-builders))) ;; Emit a profile in format version so that, if INSTANCES denotes an old ;; Guix, it can still read that profile, for instance for the purposes of ;; 'guix describe'.