From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2.migadu.com ([2001:41d0:700:3204::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms8.migadu.com with LMTPS id cOHcMNism2WE5AAAkFu2QA (envelope-from ) for ; Mon, 08 Jan 2024 09:05:44 +0100 Received: from aspmx1.migadu.com ([2001:41d0:403:4876::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2.migadu.com with LMTPS id WMAtKNism2VaMQEAe85BDQ (envelope-from ) for ; Mon, 08 Jan 2024 09:05:44 +0100 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=none; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=gnu.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1704701144; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post; bh=7ncljgaedvxNMWC3XHKCbaQfHIt0ERoex0vfV0X2ixk=; b=cGmoWauSWASa8SS+tQcvfNjlxA2G+gmr+Q8JikmoqTmOONPOXqP5SU9jKp05bbmO/FS9Xx O+a4pkjFAGAK2EDSXRmQrlghQlCwCZv92O42Gd/nc+gi5EGxV2PlwFkDcTciKzINNydjVW MHVWyyOsbiCY1wPJ05CsChe+DwxfUsbM/fmVTAVoKuAu/RlD3n94dIsr7jX2SPr5+nfw9x fJtPvOgGCx1b9vu7xkCivgmgPY9Dz+3ZjUbK/oRgF3TnTX+nky5cb3pLFCuBAUmvrzFgwY CPJyZR8iG38LCYY5XQ9N3Uk/2iwbetUs5FKLaqr//oXupqenN4qf3RNL3yIY1A== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1704701144; a=rsa-sha256; cv=none; b=CD/ejfzHi8zx3PYbIOPFJ1KXXwWBAtfqWzWsijgzK7s0FCImD2fwwuC+vU+obVfzqnLHDc q6xfHkMjPrEJUX2rKf2R6zoMYmoRBRwmCMwywJMB+VaF3+5o7iX8W4LOr0hxor75l4Ml5y ioMqbqjYVzqRtM8XADTQ1MMZtwyu8AFMeYtpL4vtgb1l3o7e4UF7hMbk+z3Khs3bZ8pncb EtaJOyE+5uvZDdTNh2ibOUQgQWHsWuB1k4XmNf5QXm7B5BEB9piNmJSVZqJ6U5ph7qjEfM zSg/6EOkk7ZdVFYJHURJ0AHzzx+vy4GkdOc73Ungas+Qiq5AuLsF9fKAp00DBg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=gnu.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 4C10777C91 for ; Mon, 8 Jan 2024 09:05:44 +0100 (CET) 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 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 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 From: Nicolas Graves via Guix-patches via Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: guix-patches-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US X-Migadu-Queue-Id: 4C10777C91 X-Migadu-Scanner: mx10.migadu.com X-Migadu-Spam-Score: -6.81 X-Spam-Score: -6.81 X-TUID: 5RPoUAK+OsiP * 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)) -- 2.41.0