aboutsummaryrefslogtreecommitdiff
path: root/doc/guix.texi
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2019-03-12 21:39:48 +0100
committerLudovic Courtès <ludo@gnu.org>2019-03-17 22:55:01 +0100
commitf258d8862852db9779945658b3a3f2b8a2a4c217 (patch)
tree901dd1a5d6f2a4e254012fb8cf644f9a796772b7 /doc/guix.texi
parent880916ac5228b9cfd6e65ac243d17f6bd12edaf9 (diff)
downloadpatches-f258d8862852db9779945658b3a3f2b8a2a4c217.tar
patches-f258d8862852db9779945658b3a3f2b8a2a4c217.tar.gz
packages: Add 'package-input-rewriting/spec'.
* guix/packages.scm (package-input-rewriting/spec): New procedure. * tests/packages.scm ("package-input-rewriting/spec") ("package-input-rewriting/spec, partial match"): New tests. * doc/guix.texi (Defining Packages): Document it.
Diffstat (limited to 'doc/guix.texi')
-rw-r--r--doc/guix.texi23
1 files changed, 23 insertions, 0 deletions
diff --git a/doc/guix.texi b/doc/guix.texi
index 139a09d1bc..6124c9c24c 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -5241,6 +5241,29 @@ with @var{libressl}. Then we use it to define a @dfn{variant} of the
This is exactly what the @option{--with-input} command-line option does
(@pxref{Package Transformation Options, @option{--with-input}}).
+The following variant of @code{package-input-rewriting} can match packages to
+be replaced by name rather than by identity.
+
+@deffn {Scheme Procedure} package-input-rewriting/spec @var{replacements}
+Return a procedure that, given a package, applies the given @var{replacements} to
+all the package graph (excluding implicit inputs). @var{replacements} is a list of
+spec/procedures pair; each spec is a package specification such as @code{"gcc"} or
+@code{"guile@@2"}, and each procedure takes a matching package and returns a
+replacement for that package.
+@end deffn
+
+The example above could be rewritten this way:
+
+@example
+(define libressl-instead-of-openssl
+ ;; Replace all the packages called "openssl" with LibreSSL.
+ (package-input-rewriting/spec `(("openssl" . ,(const libressl)))))
+@end example
+
+The key difference here is that, this time, packages are matched by spec and
+not by identity. In other words, any package in the graph that is called
+@code{openssl} will be replaced.
+
A more generic procedure to rewrite a package dependency graph is
@code{package-mapping}: it supports arbitrary changes to nodes in the
graph.