@@ -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))))))))