guix package: Add optional argument to --search-paths.
* guix/scripts/package.scm (search-path-environment-variables): Add #:kind parameter. Pass it to 'environment-variable-definition'. (display-search-paths): Add #:kind parameter and pass it to 'search-path-environment-variables'. (%options): Add an optional parameter for "--search-paths". (guix-package)[process-query]: Handle it. * tests/guix-package-net.sh: Adjust existing test. * tests/guix-package.sh: Adjust existing tests and add new test. * doc/guix.texi (Invoking guix package): Document it.
This commit is contained in:
parent
755e1147aa
commit
dbc31ab25c
@ -1098,7 +1098,7 @@ The difference between @code{--roll-back} and
|
|||||||
not make a zeroth generation, so if a specified generation does not
|
not make a zeroth generation, so if a specified generation does not
|
||||||
exist, the current generation will not be changed.
|
exist, the current generation will not be changed.
|
||||||
|
|
||||||
@item --search-paths
|
@item --search-paths[=@var{kind}]
|
||||||
@cindex search paths
|
@cindex search paths
|
||||||
Report environment variable definitions, in Bash syntax, that may be
|
Report environment variable definitions, in Bash syntax, that may be
|
||||||
needed in order to use the set of installed packages. These environment
|
needed in order to use the set of installed packages. These environment
|
||||||
@ -1113,6 +1113,18 @@ library are installed in the profile, then @code{--search-paths} will
|
|||||||
suggest setting these variables to @code{@var{profile}/include} and
|
suggest setting these variables to @code{@var{profile}/include} and
|
||||||
@code{@var{profile}/lib}, respectively.
|
@code{@var{profile}/lib}, respectively.
|
||||||
|
|
||||||
|
The typical use case is to define these environment variables in the
|
||||||
|
shell:
|
||||||
|
|
||||||
|
@example
|
||||||
|
$ eval `guix package --search-paths`
|
||||||
|
@end example
|
||||||
|
|
||||||
|
@var{kind} may be one of @code{exact}, @code{prefix}, or @code{suffix},
|
||||||
|
meaning that the returned environment variable definitions will either
|
||||||
|
be exact settings, or prefixes or suffixes of the current value of these
|
||||||
|
variables. When omitted, @var{kind} defaults to @code{exact}.
|
||||||
|
|
||||||
@item --profile=@var{profile}
|
@item --profile=@var{profile}
|
||||||
@itemx -p @var{profile}
|
@itemx -p @var{profile}
|
||||||
Use @var{profile} instead of the user's default profile.
|
Use @var{profile} instead of the user's default profile.
|
||||||
|
@ -376,10 +376,13 @@ an output path different than CURRENT-PATH."
|
|||||||
;;;
|
;;;
|
||||||
|
|
||||||
(define* (search-path-environment-variables entries profile
|
(define* (search-path-environment-variables entries profile
|
||||||
#:optional (getenv getenv))
|
#:optional (getenv getenv)
|
||||||
|
#:key (kind 'exact))
|
||||||
"Return environment variable definitions that may be needed for the use of
|
"Return environment variable definitions that may be needed for the use of
|
||||||
ENTRIES, a list of manifest entries, in PROFILE. Use GETENV to determine the
|
ENTRIES, a list of manifest entries, in PROFILE. Use GETENV to determine the
|
||||||
current settings and report only settings not already effective."
|
current settings and report only settings not already effective. KIND
|
||||||
|
must be one of 'exact, 'prefix, or 'suffix, depending on the kind of search
|
||||||
|
path definition to be returned."
|
||||||
(let ((search-paths (delete-duplicates
|
(let ((search-paths (delete-duplicates
|
||||||
(cons $PATH
|
(cons $PATH
|
||||||
(append-map manifest-entry-search-paths
|
(append-map manifest-entry-search-paths
|
||||||
@ -388,17 +391,19 @@ current settings and report only settings not already effective."
|
|||||||
((spec . value)
|
((spec . value)
|
||||||
(let ((variable (search-path-specification-variable spec))
|
(let ((variable (search-path-specification-variable spec))
|
||||||
(sep (search-path-specification-separator spec)))
|
(sep (search-path-specification-separator spec)))
|
||||||
;; TODO: Offer the choice between exact/prefix/suffix.
|
|
||||||
(environment-variable-definition variable value
|
(environment-variable-definition variable value
|
||||||
#:separator sep))))
|
#:separator sep
|
||||||
|
#:kind kind))))
|
||||||
(evaluate-search-paths search-paths (list profile)
|
(evaluate-search-paths search-paths (list profile)
|
||||||
getenv))))
|
getenv))))
|
||||||
|
|
||||||
(define (display-search-paths entries profile)
|
(define* (display-search-paths entries profile
|
||||||
|
#:key (kind 'exact))
|
||||||
"Display the search path environment variables that may need to be set for
|
"Display the search path environment variables that may need to be set for
|
||||||
ENTRIES, a list of manifest entries, in the context of PROFILE."
|
ENTRIES, a list of manifest entries, in the context of PROFILE."
|
||||||
(let* ((profile (user-friendly-profile profile))
|
(let* ((profile (user-friendly-profile profile))
|
||||||
(settings (search-path-environment-variables entries profile)))
|
(settings (search-path-environment-variables entries profile
|
||||||
|
#:kind kind)))
|
||||||
(unless (null? settings)
|
(unless (null? settings)
|
||||||
(format #t (_ "The following environment variable definitions may be needed:~%"))
|
(format #t (_ "The following environment variable definitions may be needed:~%"))
|
||||||
(format #t "~{ ~a~%~}" settings))))
|
(format #t "~{ ~a~%~}" settings))))
|
||||||
@ -533,10 +538,20 @@ Install, remove, or upgrade PACKAGES in a single transaction.\n"))
|
|||||||
(lambda (opt name arg result arg-handler)
|
(lambda (opt name arg result arg-handler)
|
||||||
(values (alist-cons 'switch-generation arg result)
|
(values (alist-cons 'switch-generation arg result)
|
||||||
#f)))
|
#f)))
|
||||||
(option '("search-paths") #f #f
|
(option '("search-paths") #f #t
|
||||||
(lambda (opt name arg result arg-handler)
|
(lambda (opt name arg result arg-handler)
|
||||||
(values (cons `(query search-paths) result)
|
(let ((kind (match arg
|
||||||
#f)))
|
((or "exact" "prefix" "suffix")
|
||||||
|
(string->symbol arg))
|
||||||
|
(#f
|
||||||
|
'exact)
|
||||||
|
(x
|
||||||
|
(leave (_ "~a: unsupported \
|
||||||
|
kind of search path~%")
|
||||||
|
x)))))
|
||||||
|
(values (cons `(query search-paths ,kind)
|
||||||
|
result)
|
||||||
|
#f))))
|
||||||
(option '(#\p "profile") #t #f
|
(option '(#\p "profile") #t #f
|
||||||
(lambda (opt name arg result arg-handler)
|
(lambda (opt name arg result arg-handler)
|
||||||
(values (alist-cons 'profile (canonicalize-profile arg)
|
(values (alist-cons 'profile (canonicalize-profile arg)
|
||||||
@ -977,12 +992,13 @@ more information.~%"))
|
|||||||
(find-packages-by-name name version)))
|
(find-packages-by-name name version)))
|
||||||
#t))
|
#t))
|
||||||
|
|
||||||
(('search-paths)
|
(('search-paths kind)
|
||||||
(let* ((manifest (profile-manifest profile))
|
(let* ((manifest (profile-manifest profile))
|
||||||
(entries (manifest-entries manifest))
|
(entries (manifest-entries manifest))
|
||||||
(profile (user-friendly-profile profile))
|
(profile (user-friendly-profile profile))
|
||||||
(settings (search-path-environment-variables entries profile
|
(settings (search-path-environment-variables entries profile
|
||||||
(const #f))))
|
(const #f)
|
||||||
|
#:kind kind)))
|
||||||
(format #t "~{~a~%~}" settings)
|
(format #t "~{~a~%~}" settings)
|
||||||
#t))
|
#t))
|
||||||
|
|
||||||
|
@ -147,7 +147,7 @@ test "`readlink_base "$profile"`" = "$profile-2-link"
|
|||||||
|
|
||||||
# Make sure LIBRARY_PATH gets listed by `--search-paths'.
|
# Make sure LIBRARY_PATH gets listed by `--search-paths'.
|
||||||
guix package --bootstrap -p "$profile" -i guile-bootstrap -i gcc-bootstrap
|
guix package --bootstrap -p "$profile" -i guile-bootstrap -i gcc-bootstrap
|
||||||
guix package --search-paths -p "$profile" | grep LIBRARY_PATH
|
guix package -p "$profile" --search-paths | grep LIBRARY_PATH
|
||||||
|
|
||||||
# Roll back so we can delete #3 below.
|
# Roll back so we can delete #3 below.
|
||||||
guix package -p "$profile" --switch-generation=2
|
guix package -p "$profile" --switch-generation=2
|
||||||
|
@ -52,8 +52,13 @@ test -L "$profile" && test -L "$profile-1-link"
|
|||||||
test -f "$profile/bin/guile"
|
test -f "$profile/bin/guile"
|
||||||
|
|
||||||
# No search path env. var. here.
|
# No search path env. var. here.
|
||||||
guix package --search-paths -p "$profile"
|
guix package -p "$profile" --search-paths
|
||||||
test "`guix package --search-paths -p "$profile" | wc -l`" = 0
|
guix package -p "$profile" --search-paths | grep '^export PATH='
|
||||||
|
test "`guix package -p "$profile" --search-paths | wc -l`" = 1 # $PATH
|
||||||
|
( set -e; set -x; \
|
||||||
|
eval `guix package --search-paths=prefix -p "$PWD/$profile"`; \
|
||||||
|
test "`type -P guile`" = "$PWD/$profile/bin/guile" ; \
|
||||||
|
type -P rm )
|
||||||
|
|
||||||
# Exit with 1 when a generation does not exist.
|
# Exit with 1 when a generation does not exist.
|
||||||
if guix package -p "$profile" --delete-generations=42;
|
if guix package -p "$profile" --delete-generations=42;
|
||||||
|
Loading…
Reference in New Issue
Block a user