summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2026-04-10 15:28:02 +0200
committerLudovic Courtès <ludo@gnu.org>2026-04-20 15:03:13 +0200
commit32b007b4348503af31e21cb0c63f84dedf791ab3 (patch)
tree3c37b648c3e2502d78e7500568c830c4de66c3d3 /doc
parent0e8a578da426ffe42baa6069443a48ce85a8912f (diff)
doc: Document ‘package/inherit’.
* doc/guix.texi (Defining Package Variants): Document ‘package/inherit’. Change-Id: I373b54d3a6978d7d2719a234b244397f68004818 Signed-off-by: Ludovic Courtès <ludo@gnu.org> Merges: #7784
Diffstat (limited to 'doc')
-rw-r--r--doc/guix.texi21
1 files changed, 19 insertions, 2 deletions
diff --git a/doc/guix.texi b/doc/guix.texi
index de755d0c6c..d53b28bd32 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -8843,12 +8843,12 @@ dependencies than the original package. For example, the default
optional dependency, you can define a variant that removes that
dependency like so:
+@findex package/inherit
@lisp
(use-modules (gnu packages gdb)) ;for 'gdb'
(define gdb-sans-guile
- (package
- (inherit gdb)
+ (package/inherit gdb
(inputs (modify-inputs inputs
(delete "guile")))))
@end lisp
@@ -8856,6 +8856,23 @@ dependency like so:
In the body of the @code{inputs} field above, @code{inputs} is bound to
the inherited value. Thus, the @code{modify-inputs} form above removes
the @code{"guile"} package from the @code{inputs} field of @code{gdb}.
+
+@quotation Note
+The example above uses @code{(package/inherit gdb @dots{})} instead of
+the usual @code{(package (inherit gdb) @dots{})}. While the latter
+would work, @code{package/inherit} does extra work: if @code{gdb} has a
+@code{replacement} field (@pxref{Security Updates}),
+@code{package/inherit} propagates the @code{inputs} changes of this
+variant to the replacement.
+
+In other words, @code{package/inherit} ensures the variant gets a
+consistent @code{replacement} when the original package has one. Thus,
+one should generally use @code{package/inherit} when creating a variant
+for the same version, but not when targeting a different version, as in
+the @code{hello} example we saw earlier, where the replacement may be
+incorrect.
+@end quotation
+
The @code{modify-inputs} macro is a helper that can prove useful anytime
you want to remove, add, or replace package inputs.