search-paths: Add 'environment-variable-definition'.
* guix/search-paths.scm (environment-variable-definition): New variable. * guix/scripts/package.scm (search-path-environment-variables): Use it.
This commit is contained in:
parent
6568d2bd6e
commit
b07901c0cc
|
@ -384,7 +384,7 @@ current settings and report only settings not already effective."
|
||||||
(append-map manifest-entry-search-paths entries))))
|
(append-map manifest-entry-search-paths entries))))
|
||||||
(filter-map (match-lambda
|
(filter-map (match-lambda
|
||||||
((variable . value)
|
((variable . value)
|
||||||
(format #f "export ~a=\"~a\"" variable value)))
|
(environment-variable-definition variable value)))
|
||||||
(evaluate-search-paths search-paths profile getenv))))
|
(evaluate-search-paths search-paths profile getenv))))
|
||||||
|
|
||||||
(define (display-search-paths entries profile)
|
(define (display-search-paths entries profile)
|
||||||
|
|
|
@ -33,7 +33,8 @@
|
||||||
|
|
||||||
search-path-specification->sexp
|
search-path-specification->sexp
|
||||||
sexp->search-path-specification
|
sexp->search-path-specification
|
||||||
evaluate-search-paths))
|
evaluate-search-paths
|
||||||
|
environment-variable-definition))
|
||||||
|
|
||||||
;;; Commentary:
|
;;; Commentary:
|
||||||
;;;
|
;;;
|
||||||
|
@ -144,4 +145,26 @@ current settings and report only settings not already effective."
|
||||||
|
|
||||||
(filter-map search-path-definition search-paths))
|
(filter-map search-path-definition search-paths))
|
||||||
|
|
||||||
|
(define* (environment-variable-definition variable value
|
||||||
|
#:key
|
||||||
|
(kind 'exact)
|
||||||
|
(separator ":"))
|
||||||
|
"Return a the definition of VARIABLE to VALUE in Bash syntax:
|
||||||
|
|
||||||
|
KIND can be either 'exact (return the definition of VARIABLE=VALUE),
|
||||||
|
'prefix (return the definition where VALUE is added as a prefix to VARIABLE's
|
||||||
|
current value), or 'suffix (return the definition where VALUE is added as a
|
||||||
|
suffix to VARIABLE's current value.) In the case of 'prefix and 'suffix,
|
||||||
|
SEPARATOR is used as the separator between VARIABLE's current value and its
|
||||||
|
prefix/suffix."
|
||||||
|
(match kind
|
||||||
|
('exact
|
||||||
|
(format #f "export ~a=\"~a\"" variable value))
|
||||||
|
('prefix
|
||||||
|
(format #f "export ~a=\"~a${~a:+~a}$~a\""
|
||||||
|
variable value variable separator variable))
|
||||||
|
('suffix
|
||||||
|
(format #f "export ~a=\"$~a${~a:+~a}~a\""
|
||||||
|
variable variable variable separator value))))
|
||||||
|
|
||||||
;;; search-paths.scm ends here
|
;;; search-paths.scm ends here
|
||||||
|
|
Loading…
Reference in New Issue