nonguix: Add package-input-grafting.

* nonguix/utils.scm (package-input-grafting): New procedure.
This commit is contained in:
Hilton Chain 2025-01-20 14:20:50 +08:00
parent 566cf65f9c
commit 419f165cab
No known key found for this signature in database
GPG Key ID: ACC66D09CA528292

View File

@ -11,7 +11,8 @@
#:use-module (guix utils)
#:use-module (guix packages)
#:use-module (gnu services)
#:export (with-transformation))
#:export (package-input-grafting
with-transformation))
(define-public (to32 package64)
"Build package for i686-linux.
@ -26,6 +27,34 @@ Only x86_64-linux and i686-linux are supported.
,@(package-arguments package64)))))
(_ package64)))
(define (package-input-grafting replacements)
"Return a procedure that, when passed a package, grafts its direct and
indirect dependencies, including implicit inputs, according to REPLACEMENTS.
REPLACEMENTS is a list of package pairs; the first element of each pair is the
package to replace, and the second one is the replacement.
Name and version of replacement packages will be padded to meet graft
requirement."
(package-input-rewriting
(map (match-lambda
((old . new)
`(,old . ,(package
(inherit old)
(replacement
(package
(inherit new)
(name
(string-pad-right
(package-name new)
(string-length (package-name old))
#\0))
(version
(string-pad-right
(package-version new)
(string-length (package-version old))
#\0))))))))
replacements)))
;; For concerns and direction of improvement, see this thread:
;; https://lists.gnu.org/archive/html/guix-devel/2024-06/msg00275.html
(define* (with-transformation proc obj #:optional (pred package?))