GNU bug report logs

#79224 [PATCH 00/43] Extend bag-build to gexps.

PackageSource(s)Maintainer(s)
guix-patches PTS Buildd Popcon
Full log

Message #11 received at 79224@debbugs.gnu.org (full text, mbox, reply):

Received: (at 79224) by debbugs.gnu.org; 12 Aug 2025 09:05:15 +0000
From debbugs-submit-bounces@debbugs.gnu.org Tue Aug 12 05:05:15 2025
Received: from localhost ([127.0.0.1]:51742 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces@debbugs.gnu.org>)
	id 1ulkwU-0007Uy-F7
	for submit@debbugs.gnu.org; Tue, 12 Aug 2025 05:05:15 -0400
Received: from 8.mo562.mail-out.ovh.net ([46.105.60.65]:44749)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <ngraves@ngraves.fr>)
 id 1ulkwI-0007RJ-Ug
 for 79224@debbugs.gnu.org; Tue, 12 Aug 2025 05:05:07 -0400
Received: from director4.derp.mail-out.ovh.net
 (director4.derp.mail-out.ovh.net [79.137.60.37])
 by mo562.mail-out.ovh.net (Postfix) with ESMTPS id 4c1QZ460ctz1yVX;
 Tue, 12 Aug 2025 09:05:00 +0000 (UTC)
Received: from director4.derp.mail-out.ovh.net
 (director4.derp.mail-out.ovh.net. [127.0.0.1])
 by director4.derp.mail-out.ovh.net (inspect_sender_mail_agent) with SMTP
 for <79224@debbugs.gnu.org>; Tue, 12 Aug 2025 09:05:00 +0000 (UTC)
Received: from mta2.priv.ovhmail-u1.ea.mail.ovh.net (unknown [10.110.168.158])
 by director4.derp.mail-out.ovh.net (Postfix) with ESMTPS id
 4c1QZ44sMBz1xrP; Tue, 12 Aug 2025 09:05:00 +0000 (UTC)
Received: from ngraves.fr (unknown [10.1.6.6])
 by mta2.priv.ovhmail-u1.ea.mail.ovh.net (Postfix) with ESMTPSA id 1AC6A3E3261; 
 Tue, 12 Aug 2025 09:04:59 +0000 (UTC)
Authentication-Results: garm.ovh; auth=pass
 (GARM-107S0011b571201-87dd-4732-9e1b-976639729e1a,
 C5D759281D113BF028CC7F145FFAF0A9AC8DF452) smtp.auth=ngraves@ngraves.fr
X-OVh-ClientIp: 176.179.146.16
From: Nicolas Graves <ngraves@ngraves.fr>
To: 79224@debbugs.gnu.org
Subject: [PATCH 01/43] guix: packages: Extend bag-build to support gexp.
Date: Tue, 12 Aug 2025 11:04:09 +0200
Message-ID: <20250812090457.19016-1-ngraves@ngraves.fr>
X-Mailer: git-send-email 2.50.1
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Ovh-Tracer-Id: 269090079801074402
X-VR-SPAMSTATE: OK
X-VR-SPAMSCORE: 0
X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgeeffedrtdefgddufeegledvucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenucenucfjughrpefhvfevufffkffogggtgfesthekredtredtjeenucfhrhhomheppfhitgholhgrshcuifhrrghvvghsuceonhhgrhgrvhgvshesnhhgrhgrvhgvshdrfhhrqeenucggtffrrghtthgvrhhnpeetveehffevvdfgtddthedvhfeguefggeffteetueeliedvhffhjeegudehleegheenucfkphepuddvjedrtddrtddruddpudejiedrudejledrudegiedrudeinecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepuddvjedrtddrtddruddpmhgrihhlfhhrohhmpehnghhrrghvvghssehnghhrrghvvghsrdhfrhdpnhgspghrtghpthhtohepvddprhgtphhtthhopeejledvvdegseguvggssghughhsrdhgnhhurdhorhhgpdhrtghpthhtohepnhhgrhgrvhgvshesnhhgrhgrvhgvshdrfhhrpdfovfetjfhoshhtpehmohehiedvmgdpmhhouggvpehsmhhtphhouhht
DKIM-Signature: a=rsa-sha256; bh=JBIhLKsf7yqX0Z6rylZvuZrPdoDe+nWN5n32aXdm10A=; 
 c=relaxed/relaxed; d=ngraves.fr; h=From;
 s=ovhmo4487190-selector1; t=1754989500; v=1;
 b=lwvM/c6cnVYXynAb0L6UvIVa8Hg35wrm6cPzem2lUv/uPnYiSE1ujSuNq78Cwp15HQjm949g
 TFLJ8lKKvJw6HZSz9hDIlWTqVCZ7rwu21GMHL7W3osPc9IR5gwWwMPvLGO/sovQtQ5e5kV2J7T0
 Te3V4Ry8Kzcjsixfum2jJCgT4kAEAPx9M7A/WwzdoWUvCFlTU8iRZ7COYZWWcba3y4SmetUZK29
 o2/dlREMRBdlnRtUIW+tGnDH83C3fsg8ZkRRwW9IqvGvT85pdrvt/B4JBw6k4JleK4Fy92UJfxG
 4tmmcrwVdlSANNAS34DXnj2ekWMG/Hzc8br9jto3gos+g==
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 79224
Cc: Nicolas Graves <ngraves@ngraves.fr>
X-BeenThere: debbugs-submit@debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request@debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit@debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request@debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request@debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces@debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces@debbugs.gnu.org>
X-Spam-Score: -1.0 (-)
Rationale: The goal of this proposition was to enable guix users to
edit build-system lower builders on-the-fly, which is currently not
possible.  This is done by keeping a higher-level representation of
the builder - a gexp rather than a derivation - as the bag-build
field.

* guix/build-system.scm (<bag>): Update comment.
* guix/packages.scm
(bag->derivation): Handle gexp bag-build. Rename current procedure to...
(bag-builder):... this procedure.
(bag->cross-derivation): Rename procedure to...
(bag-cross-builder):... this procedure.

Change-Id: I56c5a9dab9954307f95b29eab5e02ee058271684
---
 guix/build-system.scm |  2 +-
 guix/packages.scm     | 53 +++++++++++++++++++++++++++++++++++--------
 2 files changed, 45 insertions(+), 10 deletions(-)

diff --git a/guix/build-system.scm b/guix/build-system.scm
index 76d670995ce..a4dcdc52d85 100644
--- a/guix/build-system.scm
+++ b/guix/build-system.scm
@@ -79,7 +79,7 @@ (define-record-type* <bag> bag %make-bag
                  (default '("out")))
   (arguments     bag-arguments           ;list
                  (default '()))
-  (build         bag-build))             ;bag -> derivation
+  (build         bag-build))             ;bag -> gexp or derivation
 
 (define* (make-bag build-system name
                    #:key source (inputs '()) (native-inputs '())
diff --git a/guix/packages.scm b/guix/packages.scm
index 1d5986c5f42..1df9cb67f02 100644
--- a/guix/packages.scm
+++ b/guix/packages.scm
@@ -12,6 +12,7 @@
 ;;; Copyright © 2023 Simon Tournier <zimon.toutoune@gmail.com>
 ;;; Copyright © 2024 Janneke Nieuwenhuizen <janneke@gnu.org>
 ;;; Copyright © 2024 David Elsing <david.elsing@posteo.net>
+;;; Copyright © 2024 Nicolas Graves <ngraves@ngraves.fr>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -51,6 +52,7 @@ (define-module (guix packages)
   #:use-module (ice-9 match)
   #:use-module (ice-9 vlist)
   #:use-module (ice-9 regex)
+  #:use-module (ice-9 optargs)
   #:use-module (srfi srfi-1)
   #:use-module (srfi srfi-9 gnu)
   #:use-module (srfi srfi-26)
@@ -1967,12 +1969,12 @@ (define (input=? input1 input2)
                       (derivation=? obj1 obj2))
                  (equal? obj1 obj2))))))))
 
-(define* (bag->derivation bag #:optional context)
-  "Return the derivation to build BAG for SYSTEM.  Optionally, CONTEXT can be
-a package object describing the context in which the call occurs, for improved
-error reporting."
+(define* (bag-builder bag #:optional context)
+  "Return the gexp or derivation to build BAG for SYSTEM.  Optionally, CONTEXT
+can be a package object describing the context in which the call occurs, for
+improved error reporting."
   (if (bag-target bag)
-      (bag->cross-derivation bag)
+      (bag-cross-builder bag)
       (mlet* %store-monad ((system ->  (bag-system bag))
                            (inputs ->  (bag-transitive-inputs bag))
                            (input-drvs (mapm %store-monad
@@ -1994,10 +1996,10 @@ (define* (bag->derivation bag #:optional context)
                #:outputs (bag-outputs bag) #:system system
                (bag-arguments bag)))))
 
-(define* (bag->cross-derivation bag #:optional context)
-  "Return the derivation to build BAG, which is actually a cross build.
-Optionally, CONTEXT can be a package object denoting the context of the call.
-This is an internal procedure."
+(define* (bag-cross-builder bag #:optional context)
+  "Return the gexp or derivation to build BAG, which is actually a cross
+build. Optionally, CONTEXT can be a package object denoting the context of the
+call. This is an internal procedure."
   (mlet* %store-monad ((system ->   (bag-system bag))
                        (target ->   (bag-target bag))
                        (host ->     (bag-transitive-host-inputs bag))
@@ -2038,6 +2040,39 @@ (define* (bag->cross-derivation bag #:optional context)
            #:system system #:target target
            (bag-arguments bag))))
 
+(define* (bag->derivation bag #:optional context)
+  "Return the derivation to build BAG for SYSTEM.  Optionally, CONTEXT can be
+a package object describing the context in which the call occurs, for improved
+error reporting."
+  (mlet %store-monad ((builder (bag-builder bag context)))
+    (match builder
+      ((? derivation? drv)
+       (return drv))
+      ((? gexp? gexp)
+       (let-keywords (bag-arguments bag) #t
+                     ((allowed-references    #f)
+                      (disallowed-references #f)
+                      (guile                 #f)
+                      (substitutable?        #t))
+         (mlet %store-monad
+             ((guile (package->derivation (or guile (default-guile))
+                                          (bag-system bag)
+                                          #:graft? #f)))
+           ;; Note: Always pass #:graft? #f.  Without it, ALLOWED-REFERENCES &
+           ;; co. would be interpreted as referring to grafted packages.
+           (gexp->derivation (bag-name bag) gexp
+                             #:system (bag-system bag)
+                             #:target (and (bag-target bag))
+                             #:graft? #f
+                             #:substitutable? substitutable?
+                             #:allowed-references allowed-references
+                             #:disallowed-references disallowed-references
+                             #:guile-for-build guile))))
+      ;; build-bag has to be drv or gexp, else raise.
+      (_
+       (raise (condition (&package-error
+                          (package context))))))))
+
 (define bag->derivation*
   (store-lower bag->derivation))
 
-- 
2.50.1





Send a report that this bug log contains spam.


debbugs.gnu.org maintainers <help-debbugs@gnu.org>. Last modified: Wed Sep 10 05:18:57 2025; Machine Name: wallace-server

GNU bug tracking system

Debbugs is free software and licensed under the terms of the GNU Public License version 2. The current version can be obtained from https://bugs.debian.org/debbugs-source/.

Copyright © 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson, 2005-2017 Don Armstrong, and many other contributors.