discovery: 'all-modules' returns modules in path order.

A particular effect of this is that if there are ambiguous
packages in a directory specified with `-L module_dir` and the
distribution, the version from `module_dir` will be loaded,
which is usually what would be expected. (E.g. for `guix build`
or `guix package -i`.)

* guix/discovery.scm (all-modules): Return modules in path order.
* tests/guix-package.sh: Test local definitions take precedence.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
This commit is contained in:
Robert Vollmert 2019-05-25 08:40:38 +02:00 committed by Ludovic Courtès
parent dfc69e4b6d
commit 002d17dcaa
No known key found for this signature in database
GPG Key ID: 090B11993D9AEBB5
2 changed files with 16 additions and 2 deletions

View File

@ -145,8 +145,8 @@ Call (PROC MODULE RESULT) for each module that is found."
"Return the list of package modules found in PATH, a list of directories to "Return the list of package modules found in PATH, a list of directories to
search. Entries in PATH can be directory names (strings) or (DIRECTORY search. Entries in PATH can be directory names (strings) or (DIRECTORY
. SUB-DIRECTORY) pairs, in which case modules are searched for beneath . SUB-DIRECTORY) pairs, in which case modules are searched for beneath
SUB-DIRECTORY." SUB-DIRECTORY. Modules are listed in the order they appear on the path."
(fold-modules cons '() path #:warn warn)) (reverse (fold-modules cons '() path #:warn warn)))
(define (fold-module-public-variables* proc init modules) (define (fold-module-public-variables* proc init modules)
"Call (PROC MODULE SYMBOL VARIABLE) for each variable exported by one of MODULES, "Call (PROC MODULE SYMBOL VARIABLE) for each variable exported by one of MODULES,

View File

@ -280,6 +280,20 @@ export GUIX_PACKAGE_PATH
guix package -A emacs-foo-bar | grep 42 guix package -A emacs-foo-bar | grep 42
guix package -i emacs-foo-bar@42 -n guix package -i emacs-foo-bar@42 -n
# Make sure GUIX_PACKAGE_PATH/'-L' takes precedence in case of duplicate packages.
cat > "$module_dir/bar.scm"<<EOF
(define-module (bar)
#:use-module (guix packages))
(define-public hello
(package (inherit (@@ (gnu packages base) hello))
(synopsis "an overridden version of GNU hello")))
EOF
guix package -i hello -n 2>&1 | grep choosing.*bar.scm
( unset GUIX_PACKAGE_PATH; \
guix package -i hello -n -L "$module_dir" 2>&1 | grep choosing.*bar.scm )
# Make sure patches that live under $GUIX_PACKAGE_PATH are found. # Make sure patches that live under $GUIX_PACKAGE_PATH are found.
cat > "$module_dir/emacs.patch"<<EOF cat > "$module_dir/emacs.patch"<<EOF
This is a fake patch. This is a fake patch.