diff options
Diffstat (limited to 'guix')
-rw-r--r-- | guix/build/profiles.scm | 24 | ||||
-rw-r--r-- | guix/build/utils.scm | 13 | ||||
-rw-r--r-- | guix/search-paths.scm | 28 |
3 files changed, 44 insertions, 21 deletions
diff --git a/guix/build/profiles.scm b/guix/build/profiles.scm index 6e316d5d2c..42eabfaf19 100644 --- a/guix/build/profiles.scm +++ b/guix/build/profiles.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2015 Ludovic Courtès <ludo@gnu.org> +;;; Copyright © 2015, 2017 Ludovic Courtès <ludo@gnu.org> ;;; ;;; This file is part of GNU Guix. ;;; @@ -39,17 +39,21 @@ 'GUIX_PROFILE' environment variable. This allows users to specify what the user-friendly name of the profile is, for instance ~/.guix-profile rather than /gnu/store/...-profile." - (let ((replacement (string-append "${GUIX_PROFILE:-" profile "}"))) + (let ((replacement (string-append "${GUIX_PROFILE:-" profile "}")) + (crop (cute string-drop <> (string-length profile)))) (match-lambda ((search-path . value) - (let* ((separator (search-path-specification-separator search-path)) - (items (string-tokenize* value separator)) - (crop (cute string-drop <> (string-length profile)))) - (cons search-path - (string-join (map (lambda (str) - (string-append replacement (crop str))) - items) - separator))))))) + (match (search-path-specification-separator search-path) + (#f + (cons search-path + (string-append replacement (crop value)))) + ((? string? separator) + (let ((items (string-tokenize* value separator))) + (cons search-path + (string-join (map (lambda (str) + (string-append replacement (crop str))) + items) + separator))))))))) (define (write-environment-variable-definition port) "Write the given environment variable definition to PORT." diff --git a/guix/build/utils.scm b/guix/build/utils.scm index bc6f114152..cf09326393 100644 --- a/guix/build/utils.scm +++ b/guix/build/utils.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2012, 2013, 2014, 2015, 2016 Ludovic Courtès <ludo@gnu.org> +;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017 Ludovic Courtès <ludo@gnu.org> ;;; Copyright © 2013 Andreas Enge <andreas@enge.fr> ;;; Copyright © 2013 Nikita Karetnikov <nikita@karetnikov.org> ;;; Copyright © 2015 Mark H Weaver <mhw@netris.org> @@ -400,10 +400,17 @@ for under the directories designated by FILES. For example: (delete-duplicates input-dirs))) (define (list->search-path-as-string lst separator) - (string-join lst separator)) + (if separator + (string-join lst separator) + (match lst + ((head rest ...) head) + (() "")))) (define* (search-path-as-string->list path #:optional (separator #\:)) - (string-tokenize path (char-set-complement (char-set separator)))) + (if separator + (string-tokenize path + (char-set-complement (char-set separator))) + (list path))) (define* (set-path-environment-variable env-var files input-dirs #:key diff --git a/guix/search-paths.scm b/guix/search-paths.scm index 7a6fe67959..4bf0e44389 100644 --- a/guix/search-paths.scm +++ b/guix/search-paths.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2013, 2014, 2015 Ludovic Courtès <ludo@gnu.org> +;;; Copyright © 2013, 2014, 2015, 2017 Ludovic Courtès <ludo@gnu.org> ;;; ;;; This file is part of GNU Guix. ;;; @@ -55,7 +55,7 @@ search-path-specification? (variable search-path-specification-variable) ;string (files search-path-specification-files) ;list of strings - (separator search-path-specification-separator ;string + (separator search-path-specification-separator ;string | #f (default ":")) (file-type search-path-specification-file-type ;symbol (default 'directory)) @@ -131,11 +131,23 @@ like `string-tokenize', but SEPARATOR is a string." DIRECTORIES, a list of directory names, and return a list of specification/value pairs. Use GETENV to determine the current settings and report only settings not already effective." - (define search-path-definition - (match-lambda - ((and spec - ($ <search-path-specification> variable files separator - type pattern)) + (define (search-path-definition spec) + (match spec + (($ <search-path-specification> variable files #f type pattern) + ;; Separator is #f so return the first match. + (match (with-null-error-port + (search-path-as-list files directories + #:type type + #:pattern pattern)) + (() + #f) + ((head . _) + (let ((value (getenv variable))) + (if (and value (string=? value head)) + #f ;VARIABLE already set appropriately + (cons spec head)))))) + (($ <search-path-specification> variable files separator + type pattern) (let* ((values (or (and=> (getenv variable) (cut string-tokenize* <> separator)) '())) @@ -164,7 +176,7 @@ 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 + (match (if (not separator) 'exact kind) ('exact (format #f "export ~a=\"~a\"" variable value)) ('prefix |