guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

03/04: packages: 'package-input-rewriting' can take a promise.


From: guix-commits
Subject: 03/04: packages: 'package-input-rewriting' can take a promise.
Date: Mon, 28 Jan 2019 09:48:39 -0500 (EST)

civodul pushed a commit to branch master
in repository guix.

commit 7d2be1277b44de9d0528d9d3015443b40cb3b104
Author: Ludovic Courtès <address@hidden>
Date:   Mon Jan 28 15:41:12 2019 +0100

    packages: 'package-input-rewriting' can take a promise.
    
    * guix/packages.scm (package-input-rewriting): Allow REPLACEMENTS to be
    a promise.
    * gnu/packages/guile.scm (package-for-guile-2.0): Delay the first
    argument to 'package-input-rewriting'.
---
 gnu/packages/guile.scm |  2 +-
 guix/packages.scm      | 16 ++++++++++++----
 2 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/gnu/packages/guile.scm b/gnu/packages/guile.scm
index 869fec9..5f5d59d 100644
--- a/gnu/packages/guile.scm
+++ b/gnu/packages/guile.scm
@@ -391,7 +391,7 @@ address@hidden  Use the @code{(ice-9 readline)} module and 
call its
 (define package-for-guile-2.0
   ;; A procedure that rewrites the dependency tree of the given package to use
   ;; GUILE-2.0 instead of GUILE-2.2.
-  (package-input-rewriting `((,guile-2.2 . ,guile-2.0))
+  (package-input-rewriting (delay `((,guile-2.2 . ,guile-2.0)))
                            (guile-variant-package-name "guile2.0")))
 
 (define-public guile-for-guile-emacs
diff --git a/guix/packages.scm b/guix/packages.scm
index f191327..8515bb7 100644
--- a/guix/packages.scm
+++ b/guix/packages.scm
@@ -855,19 +855,27 @@ when CUT? returns true for a given package."
                                   #:optional (rewrite-name identity))
   "Return a procedure that, when passed a package, replaces its direct and
 indirect dependencies (but not its 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.
+REPLACEMENTS is a list of package pairs or a promise thereof; the first
+element of each pair is the package to replace, and the second one is the
+replacement.
 
 Optionally, REWRITE-NAME is a one-argument procedure that takes the name of a
 package and returns its new name after rewrite."
   (define (rewrite p)
-    (match (assq-ref replacements p)
+    (match (assq-ref (if (promise? replacements)
+                         (force replacements)
+                         replacements)
+                     p)
       (#f  (package
              (inherit p)
              (name (rewrite-name (package-name p)))))
       (new new)))
 
-  (package-mapping rewrite (cut assq <> replacements)))
+  (package-mapping rewrite
+                   (lambda (package)
+                     (assq package (if (promise? replacements)
+                                       (force replacements)
+                                       replacements)))))
 
 (define-syntax-rule (package/inherit p overrides ...)
   "Like (package (inherit P) OVERRIDES ...), except that the same



reply via email to

[Prev in Thread] Current Thread [Next in Thread]