diff options
author | Marius Bakke <mbakke@fastmail.com> | 2019-03-23 23:16:55 +0100 |
---|---|---|
committer | Marius Bakke <mbakke@fastmail.com> | 2019-03-23 23:16:55 +0100 |
commit | 8c14f7f8a7ab0722bf4c9f92fd28ae85514d564f (patch) | |
tree | adc5d29e9c2dcda5befa0ca81f1af8df23294947 /guix/packages.scm | |
parent | 2f33a7321e5e37d37f57c229c8079cb4ffd10834 (diff) | |
parent | 3374e9207f5244c20402a3c5513fe562140fef47 (diff) |
Merge branch 'staging' into core-updates
Diffstat (limited to 'guix/packages.scm')
-rw-r--r-- | guix/packages.scm | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/guix/packages.scm b/guix/packages.scm index 1893539aab..a961dc3973 100644 --- a/guix/packages.scm +++ b/guix/packages.scm @@ -102,6 +102,7 @@ package-transitive-supported-systems package-mapping package-input-rewriting + package-input-rewriting/spec package-source-derivation package-derivation package-cross-derivation @@ -871,6 +872,43 @@ package and returns its new name after rewrite." (package-mapping rewrite (cut assq <> replacements))) +(define (package-input-rewriting/spec replacements) + "Return a procedure that, given a package, applies the given REPLACEMENTS to +all the package graph (excluding implicit inputs). REPLACEMENTS is a list of +spec/procedures pair; each spec is a package specification such as \"gcc\" or +\"guile@2\", and each procedure takes a matching package and returns a +replacement for that package." + (define table + (fold (lambda (replacement table) + (match replacement + ((spec . proc) + (let-values (((name version) + (package-name->name+version spec))) + (vhash-cons name (list version proc) table))))) + vlist-null + replacements)) + + (define (find-replacement package) + (vhash-fold* (lambda (item proc) + (or proc + (match item + ((#f proc) + proc) + ((version proc) + (and (version-prefix? version + (package-version package)) + proc))))) + #f + (package-name package) + table)) + + (define (rewrite package) + (match (find-replacement package) + (#f package) + (proc (proc package)))) + + (package-mapping rewrite find-replacement)) + (define-syntax-rule (package/inherit p overrides ...) "Like (package (inherit P) OVERRIDES ...), except that the same transformation is done to the package replacement, if any. P must be a bare |