From 419f165cabbaf8f1c779787f50bd615ded8eee3c Mon Sep 17 00:00:00 2001 From: Hilton Chain Date: Mon, 20 Jan 2025 14:20:50 +0800 Subject: [PATCH] nonguix: Add package-input-grafting. * nonguix/utils.scm (package-input-grafting): New procedure. --- nonguix/utils.scm | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/nonguix/utils.scm b/nonguix/utils.scm index 4deb597..9dc5b21 100644 --- a/nonguix/utils.scm +++ b/nonguix/utils.scm @@ -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?))