From patchwork Mon Jan 8 08:02:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Nicolas Graves X-Patchwork-Id: 58620 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 4D2B027BBE2; Mon, 8 Jan 2024 08:05:45 +0000 (GMT) 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 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 3D9F627BBE9 for ; Mon, 8 Jan 2024 08:05:44 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rMkd0-0003Eh-Cr; Mon, 08 Jan 2024 03:04:58 -0500 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 1rMkcy-0003DM-Py for guix-patches@gnu.org; Mon, 08 Jan 2024 03:04:56 -0500 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 1rMkcy-0002le-HI for guix-patches@gnu.org; Mon, 08 Jan 2024 03:04:56 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rMkd4-0007zs-HF for guix-patches@gnu.org; Mon, 08 Jan 2024 03:05:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#68315] [PATCH 01/48] guix: packages: Extend bag-build to support gexp. References: <20240108080048.25026-1-ngraves@ngraves.fr> In-Reply-To: <20240108080048.25026-1-ngraves@ngraves.fr> Resent-From: Nicolas Graves Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 08 Jan 2024 08:05:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 68315 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 68315@debbugs.gnu.org Cc: ngraves@ngraves.fr Received: via spool by 68315-submit@debbugs.gnu.org id=B68315.170470104830103 (code B ref 68315); Mon, 08 Jan 2024 08:05:02 +0000 Received: (at 68315) by debbugs.gnu.org; 8 Jan 2024 08:04:08 +0000 Received: from localhost ([127.0.0.1]:34898 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rMkcB-0007pS-FK for submit@debbugs.gnu.org; Mon, 08 Jan 2024 03:04:07 -0500 Received: from 6.mo576.mail-out.ovh.net ([46.105.50.107]:41433) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rMkc8-0007p8-9U for 68315@debbugs.gnu.org; Mon, 08 Jan 2024 03:04:05 -0500 Received: from director5.ghost.mail-out.ovh.net (unknown [10.108.9.153]) by mo576.mail-out.ovh.net (Postfix) with ESMTP id D196C2F9FB for <68315@debbugs.gnu.org>; Mon, 8 Jan 2024 08:03:56 +0000 (UTC) Received: from ghost-submission-6684bf9d7b-mnvcv (unknown [10.109.176.19]) by director5.ghost.mail-out.ovh.net (Postfix) with ESMTPS id 53D421FE9D; Mon, 8 Jan 2024 08:03:56 +0000 (UTC) Received: from ngraves.fr ([37.59.142.108]) by ghost-submission-6684bf9d7b-mnvcv with ESMTPSA id xo6pC2ysm2WDAwAAlH3eGw (envelope-from ); Mon, 08 Jan 2024 08:03:56 +0000 Authentication-Results: garm.ovh; auth=pass (GARM-108S002fcf82da2-9559-4fe7-bfa9-bbd35ead7bd9, 93F3D688BC7B2D554E6C57CDC3775C4FA39180DF) smtp.auth=ngraves@ngraves.fr X-OVh-ClientIp: 81.67.146.208 Date: Mon, 8 Jan 2024 09:02:33 +0100 Message-ID: <20240108080350.1665-1-ngraves@ngraves.fr> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 X-Ovh-Tracer-Id: 12424305473771791074 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: 0 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvkedrvdehiedgheduucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenucenucfjughrpefhvfevufffkffogggtgfesthekredtredtjeenucfhrhhomheppfhitgholhgrshcuifhrrghvvghsuceonhhgrhgrvhgvshesnhhgrhgrvhgvshdrfhhrqeenucggtffrrghtthgvrhhnpeetveehffevvdfgtddthedvhfeguefggeffteetueeliedvhffhjeegudehleegheenucfkphepuddvjedrtddrtddruddpkedurdeijedrudegiedrvddtkedpfeejrdehledrudegvddruddtkeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepihhnvghtpeduvdejrddtrddtrddupdhmrghilhhfrhhomhepoehnghhrrghvvghssehnghhrrghvvghsrdhfrheqpdhnsggprhgtphhtthhopedupdhrtghpthhtohepieekfeduheesuggvsggsuhhgshdrghhnuhdrohhrghdpoffvtefjohhsthepmhhoheejiedpmhhouggvpehsmhhtphhouhht 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: , Reply-to: Nicolas Graves X-ACL-Warn: , Nicolas Graves via Guix-patches X-Patchwork-Original-From: Nicolas Graves via Guix-patches via From: Nicolas Graves 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 * guix/build-system.scm: Update comment. * guix/packages.scm (bag->derivation): Rename function to bag-builder. Create new function. (bag->cross-derivation): Rename to bag-cross-builder. 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 76d670995c..a4dcdc52d8 100644 --- a/guix/build-system.scm +++ b/guix/build-system.scm @@ -79,7 +79,7 @@ (define-record-type* 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 930b1a3b0e..8ff9ca60a9 100644 --- a/guix/packages.scm +++ b/guix/packages.scm @@ -10,6 +10,7 @@ ;;; Copyright © 2022 Maxime Devos ;;; Copyright © 2022 jgart ;;; Copyright © 2023 Simon Tournier +;;; Copyright © 2024 Nicolas Graves ;;; ;;; This file is part of GNU Guix. ;;; @@ -50,6 +51,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) @@ -1889,12 +1891,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 @@ -1916,10 +1918,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)) @@ -1960,6 +1962,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))