packages: 'package-input-rewriting/spec' can rewrite implicit dependencies.
authorLudovic Courtès <ludo@gnu.org>
Wed, 23 Sep 2020 08:29:09 +0000 (10:29 +0200)
committerLudovic Courtès <ludo@gnu.org>
Sun, 27 Sep 2020 19:41:08 +0000 (21:41 +0200)
commit2bf6f962b91123b0474c0f7123cd17efe7f09a66
tree21f74da9ad3b3eaacf91cd63302bea01f55bedb9
parentff39361c80dfc67a9afe35f315a774140d8cf99b
packages: 'package-input-rewriting/spec' can rewrite implicit dependencies.

With this change, '--with-input', '--with-graft', etc. also apply to
implicit dependencies.  Thus, it's now possible to do:

  guix build python-itsdangerous --with-input=python-wrapper=python@2

or:

  guix build hello --with-graft=glibc=glibc@2.29

Additionally, before, implicit inputs were not rewritten, which could
lead to duplicates in the output of 'bag-transitive-inputs' (packages
that are not 'eq?' but lead to the same derivation).  This in turn would
lead to unnecessary rebuilds when using '--with-input' & co.  This
change fixes it by ensuring even implicit inputs are rewritten.

Fixes <https://bugs.gnu.org/42156>.

* guix/packages.scm (package-input-rewriting/spec): Add #:deep?
defaulting to #true, and pass it to 'package-mapping'.
[replacement-property]: New variable.
[rewrite]: Check that property and set it on the result of PROC.
[cut?]: New procedure.
* tests/packages.scm ("package-input-rewriting/spec"): Ensure implicit
inputs were unchanged.
("package-input-rewriting/spec, partial match"): Pass #:deep? #f.
("package-input-rewriting/spec, deep")
("package-input-rewriting/spec, no duplicates"): New tests.
(package/inherit): Move before use.
* tests/guix-build.sh: Add tests.
* tests/scripts-build.scm ("options->transformation, with-graft"):
Compare dependencies by package name or derivation file name.
* doc/guix.texi (Defining Packages): Adjust accordingly.
doc/guix.texi
guix/packages.scm
tests/guix-build.sh
tests/packages.scm
tests/scripts-build.scm