unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: Christopher Baines <mail@cbaines.net>
To: 61363@debbugs.gnu.org
Cc: ludo@gnu.org
Subject: [bug#61363] [PATCH 1/2] packages: Add explicit-grafting record type to assist with grafts.
Date: Wed,  8 Feb 2023 08:54:02 +0100	[thread overview]
Message-ID: <20230208075403.11788-1-mail@cbaines.net> (raw)
In-Reply-To: <871qn08uo7.fsf@cbaines.net>

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: <https://issues.guix.gnu.org/52694>.
@@ -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>
+  (%explicit-grafting obj packages)
+  explicit-grafting?
+  (obj      explicit-grafting-obj)       ;obj
+  (packages explicit-grafting-packages)) ;list of <package>s
+
+(define (write-explicit-grafting rec port)
+  (match rec
+    (($ <explicit-grafting> obj packages)
+     (format port "#<explicit-grafting ~s ~s>" obj packages))))
+
+(define (explicit-grafting obj packages)
+  (%explicit-grafting obj packages))
+
+(define-gexp-compiler (explicit-grafting-compiler (explicit-grafting <explicit-grafting>)
+                                                  system target)
+  (match explicit-grafting
+    (($ <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))))))))
-- 
2.38.1





  reply	other threads:[~2023-02-08  7:55 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-08  7:46 [bug#61363] [PATCH 0/2] self: Apply grafts to the outputs of the guix derivation Christopher Baines
2023-02-08  7:54 ` Christopher Baines [this message]
2023-02-08  7:54   ` [bug#61363] [PATCH 2/2] " Christopher Baines
2023-02-22  9:16     ` Ludovic Courtès
2023-02-22 11:17       ` Christopher Baines
2023-02-28 15:47         ` Christopher Baines
2023-04-17 15:06           ` Christopher Baines
2023-02-10  9:16 ` [bug#61363] [PATCH 0/2] " Christopher Baines
2023-02-28 15:47 ` [bug#61363] [PATCH v2 1/3] packages: Export guile-for-grafts Christopher Baines
2023-02-28 15:47   ` [bug#61363] [PATCH v2 2/3] self: Restructure accessing packages Christopher Baines
2023-02-28 15:47   ` [bug#61363] [PATCH v2 3/3] self: Apply grafts to the outputs of the guix derivation Christopher Baines
2023-04-17 14:59 ` [bug#61363] [PATCH v3] " Christopher Baines
2023-05-16 13:25   ` Simon Tournier
2023-06-03 11:41     ` Christopher Baines

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230208075403.11788-1-mail@cbaines.net \
    --to=mail@cbaines.net \
    --cc=61363@debbugs.gnu.org \
    --cc=ludo@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).