From patchwork Wed Feb 8 07:54:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christopher Baines X-Patchwork-Id: 46738 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 5ACE516D47; Wed, 8 Feb 2023 07:55:24 +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=-3.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_MSPIKE_H2,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 4811A16D3C for ; Wed, 8 Feb 2023 07:55:23 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pPfIJ-0000fW-Oj; Wed, 08 Feb 2023 02:55:09 -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 1pPfIG-0000f3-IC for guix-patches@gnu.org; Wed, 08 Feb 2023 02:55:04 -0500 Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pPfIE-0002P4-47; Wed, 08 Feb 2023 02:55:03 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pPfID-0000Ac-HY; Wed, 08 Feb 2023 02:55:01 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#61363] [PATCH 1/2] packages: Add explicit-grafting record type to assist with grafts. References: <871qn08uo7.fsf@cbaines.net> In-Reply-To: <871qn08uo7.fsf@cbaines.net> Resent-From: Christopher Baines Original-Sender: "Debbugs-submit" Resent-CC: ludo@gnu.org, guix-patches@gnu.org Resent-Date: Wed, 08 Feb 2023 07:55:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 61363 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 61363@debbugs.gnu.org Cc: ludo@gnu.org X-Debbugs-Original-Xcc: ludo@gnu.org Received: via spool by 61363-submit@debbugs.gnu.org id=B61363.1675842847578 (code B ref 61363); Wed, 08 Feb 2023 07:55:01 +0000 Received: (at 61363) by debbugs.gnu.org; 8 Feb 2023 07:54:07 +0000 Received: from localhost ([127.0.0.1]:54683 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pPfHL-00009F-8S for submit@debbugs.gnu.org; Wed, 08 Feb 2023 02:54:07 -0500 Received: from mira.cbaines.net ([212.71.252.8]:42176) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pPfHJ-000091-K3 for 61363@debbugs.gnu.org; Wed, 08 Feb 2023 02:54:06 -0500 Received: from localhost (unknown [IPv6:2a02:1808:280:f63d:f055:17e:cfb4:3]) by mira.cbaines.net (Postfix) with ESMTPSA id 9081C16D28 for <61363@debbugs.gnu.org>; Wed, 8 Feb 2023 07:54:04 +0000 (GMT) Received: from localhost (localhost [local]) by localhost (OpenSMTPD) with ESMTPA id eac9e016 for <61363@debbugs.gnu.org>; Wed, 8 Feb 2023 07:54:03 +0000 (UTC) From: Christopher Baines Date: Wed, 8 Feb 2023 08:54:02 +0100 Message-Id: <20230208075403.11788-1-mail@cbaines.net> X-Mailer: git-send-email 2.38.1 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 Normally the grafting takes place when lowering packages, but this record assists with applying the same transformation to arbitrary objects/store items. I'm adding this to allow grafting the channel instance derivation outputs. * guix/packages.scm (explicit-grafting, explicit-grafting?, explicit-grafting-obj, explicit-grafting-grafts): New procedures. --- guix/packages.scm | 45 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/guix/packages.scm b/guix/packages.scm index 041a872f9d..877bf89522 100644 --- a/guix/packages.scm +++ b/guix/packages.scm @@ -188,7 +188,12 @@ (define-module (guix packages) package-file package->derivation package->cross-derivation - origin->derivation)) + origin->derivation + + explicit-grafting + explicit-grafting? + explicit-grafting-obj + explicit-grafting-grafts)) ;; The 'source-module-closure' procedure ca. 1.2.0 did not recognize ;; #:re-export-and-replace: . @@ -2093,3 +2098,41 @@ (define package-source-derivation ;somewhat deprecated (add-to-store store (basename file) #t "sha256" file)) (_ (lower store source system)))))) + +;; Apply grafts explicitly +(define-immutable-record-type + (%explicit-grafting obj packages) + explicit-grafting? + (obj explicit-grafting-obj) ;obj + (packages explicit-grafting-packages)) ;list of s + +(define (write-explicit-grafting rec port) + (match rec + (($ obj packages) + (format port "#" obj packages)))) + +(define (explicit-grafting obj packages) + (%explicit-grafting obj packages)) + +(define-gexp-compiler (explicit-grafting-compiler (explicit-grafting ) + system target) + (match explicit-grafting + (($ obj packages) + (mlet* %store-monad ((drv (without-grafting + (lower-object obj system #:target target))) + (grafts + (mapm %store-monad + (lambda (pkg) + (package-grafts* pkg system #:target target)) + packages))) + (match (delete-duplicates + (concatenate grafts)) + (() + (return drv)) + (grafts + (mlet %store-monad ((guile (package->derivation + (guile-for-grafts) + system #:graft? #f))) + (graft-derivation* drv grafts + #:system system + #:guile guile))))))))