aboutsummaryrefslogtreecommitdiff
path: root/guix/search-paths.scm
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2015-05-04 22:06:24 +0200
committerLudovic Courtès <ludo@gnu.org>2015-05-04 23:30:52 +0200
commitb07901c0cc5b36efdc92263ddeaa2be28cf2f398 (patch)
treeb9c1902ba9ecc29697e5fb6fd58c444ee891ec63 /guix/search-paths.scm
parent6568d2bd6e4e047dd95b00a7a6e7501a16491eb5 (diff)
downloadgnu-guix-b07901c0cc5b36efdc92263ddeaa2be28cf2f398.tar
gnu-guix-b07901c0cc5b36efdc92263ddeaa2be28cf2f398.tar.gz
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.
Diffstat (limited to 'guix/search-paths.scm')
-rw-r--r--guix/search-paths.scm25
1 files changed, 24 insertions, 1 deletions
diff --git a/guix/search-paths.scm b/guix/search-paths.scm
index b17f5acd5d..7957c88241 100644
--- a/guix/search-paths.scm
+++ b/guix/search-paths.scm
@@ -33,7 +33,8 @@
search-path-specification->sexp
sexp->search-path-specification
- evaluate-search-paths))
+ evaluate-search-paths
+ environment-variable-definition))
;;; Commentary:
;;;
@@ -144,4 +145,26 @@ current settings and report only settings not already effective."
(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