guix package: Introduce 'evaluate-search-paths'.
* guix/scripts/package.scm (evaluate-search-paths): New procedure, with most of the code formerly in 'search-path-environment-variables'. (search-path-environment-variables): Use it.
This commit is contained in:
parent
3badccaa73
commit
4e9f592058
|
@ -379,10 +379,10 @@ an output path different than CURRENT-PATH."
|
||||||
(with-error-to-port (%make-void-port "w")
|
(with-error-to-port (%make-void-port "w")
|
||||||
(lambda () exp)))
|
(lambda () exp)))
|
||||||
|
|
||||||
(define* (search-path-environment-variables entries profile
|
(define* (evaluate-search-paths search-paths directory
|
||||||
#:optional (getenv getenv))
|
#:optional (getenv (const #f)))
|
||||||
"Return environment variable definitions that may be needed for the use of
|
"Evaluate SEARCH-PATHS, a list of search-path specifications, for DIRECTORY,
|
||||||
ENTRIES, a list of manifest entries, in PROFILE. Use GETENV to determine the
|
and return a list of variable/value pairs. Use GETENV to determine the
|
||||||
current settings and report only settings not already effective."
|
current settings and report only settings not already effective."
|
||||||
(define search-path-definition
|
(define search-path-definition
|
||||||
(match-lambda
|
(match-lambda
|
||||||
|
@ -401,18 +401,26 @@ current settings and report only settings not already effective."
|
||||||
;; directories (see
|
;; directories (see
|
||||||
;; <http://lists.gnu.org/archive/html/guix-devel/2015-01/msg00269.html>.)
|
;; <http://lists.gnu.org/archive/html/guix-devel/2015-01/msg00269.html>.)
|
||||||
(path (with-null-error-port
|
(path (with-null-error-port
|
||||||
(search-path-as-list files (list profile)
|
(search-path-as-list files (list directory)
|
||||||
#:type type
|
#:type type
|
||||||
#:pattern pattern))))
|
#:pattern pattern))))
|
||||||
(if (every (cut member <> values) path)
|
(if (every (cut member <> values) path)
|
||||||
#f
|
#f ;VARIABLE is already set appropriately
|
||||||
(format #f "export ~a=\"~a\""
|
(cons variable (string-join path separator)))))))
|
||||||
variable
|
|
||||||
(string-join path separator)))))))
|
|
||||||
|
|
||||||
|
(filter-map search-path-definition search-paths))
|
||||||
|
|
||||||
|
(define* (search-path-environment-variables entries profile
|
||||||
|
#:optional (getenv getenv))
|
||||||
|
"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
|
||||||
|
current settings and report only settings not already effective."
|
||||||
(let ((search-paths (delete-duplicates
|
(let ((search-paths (delete-duplicates
|
||||||
(append-map manifest-entry-search-paths entries))))
|
(append-map manifest-entry-search-paths entries))))
|
||||||
(filter-map search-path-definition search-paths)))
|
(filter-map (match-lambda
|
||||||
|
((variable . value)
|
||||||
|
(format #f "export ~a=\"~a\"" variable value)))
|
||||||
|
(evaluate-search-paths search-paths profile getenv))))
|
||||||
|
|
||||||
(define (display-search-paths entries profile)
|
(define (display-search-paths entries profile)
|
||||||
"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
|
||||||
|
|
Loading…
Reference in New Issue