1
0
mirror of https://git.savannah.gnu.org/git/guix.git synced 2026-05-24 18:11:51 +02:00

packages: Add 'package-mapping' and base 'package-input-rewriting' on it.

* guix/packages.scm (package-mapping): New procedure.
(package-input-rewriting): Rewrite in terms of 'package-mapping'.
* tests/packages.scm ("package-mapping"): New test.
* doc/guix.texi (Defining Packages): Document it.
This commit is contained in:
Ludovic Courtès
2017-04-05 15:19:15 +02:00
parent 79f912c710
commit f37f2b83fa
3 changed files with 74 additions and 19 deletions
+27
View File
@@ -886,6 +886,33 @@
(and (build-derivations %store (list drv))
(file-exists? (string-append out "/bin/make")))))))
(test-equal "package-mapping"
42
(let* ((dep (dummy-package "chbouib"
(native-inputs `(("x" ,grep)))))
(p0 (dummy-package "example"
(inputs `(("foo" ,coreutils)
("bar" ,grep)
("baz" ,dep)))))
(transform (lambda (p)
(package (inherit p) (source 42))))
(rewrite (package-mapping transform))
(p1 (rewrite p0)))
(and (eq? p1 (rewrite p0))
(eqv? 42 (package-source p1))
(match (package-inputs p1)
((("foo" dep1) ("bar" dep2) ("baz" dep3))
(and (eq? dep1 (rewrite coreutils)) ;memoization
(eq? dep2 (rewrite grep))
(eq? dep3 (rewrite dep))
(eqv? 42
(package-source dep1) (package-source dep2)
(package-source dep3))
(match (package-native-inputs dep3)
((("x" dep))
(and (eq? dep (rewrite grep))
(package-source dep))))))))))
(test-assert "package-input-rewriting"
(let* ((dep (dummy-package "chbouib"
(native-inputs `(("x" ,grep)))))