summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2015-05-03 23:01:35 +0200
committerLudovic Courtès <ludo@gnu.org>2015-05-04 00:24:21 +0200
commit4e9f59205835e148d4329e7d77c81dccfacd4ea2 (patch)
tree9a3d494445b223a05f6d6f4e2ec250918a760b84
parent3badccaa7368fd2acc640b48c1dd3c1c2ae32500 (diff)
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.
-rw-r--r--guix/scripts/package.scm28
1 files changed, 18 insertions, 10 deletions
diff --git a/guix/scripts/package.scm b/guix/scripts/package.scm
index d9bad7ba87c..003f6958ef4 100644
--- a/guix/scripts/package.scm
+++ b/guix/scripts/package.scm
@@ -379,10 +379,10 @@ an output path different than CURRENT-PATH."
379 (with-error-to-port (%make-void-port "w") 379 (with-error-to-port (%make-void-port "w")
380 (lambda () exp))) 380 (lambda () exp)))
381 381
382(define* (search-path-environment-variables entries profile 382(define* (evaluate-search-paths search-paths directory
383 #:optional (getenv getenv)) 383 #:optional (getenv (const #f)))
384 "Return environment variable definitions that may be needed for the use of 384 "Evaluate SEARCH-PATHS, a list of search-path specifications, for DIRECTORY,
385ENTRIES, a list of manifest entries, in PROFILE. Use GETENV to determine the 385and return a list of variable/value pairs. Use GETENV to determine the
386current settings and report only settings not already effective." 386current settings and report only settings not already effective."
387 (define search-path-definition 387 (define search-path-definition
388 (match-lambda 388 (match-lambda
@@ -401,18 +401,26 @@ current settings and report only settings not already effective."
401 ;; directories (see 401 ;; directories (see
402 ;; <http://lists.gnu.org/archive/html/guix-devel/2015-01/msg00269.html>.) 402 ;; <http://lists.gnu.org/archive/html/guix-devel/2015-01/msg00269.html>.)
403 (path (with-null-error-port 403 (path (with-null-error-port
404 (search-path-as-list files (list profile) 404 (search-path-as-list files (list directory)
405 #:type type 405 #:type type
406 #:pattern pattern)))) 406 #:pattern pattern))))
407 (if (every (cut member <> values) path) 407 (if (every (cut member <> values) path)
408 #f 408 #f ;VARIABLE is already set appropriately
409 (format #f "export ~a=\"~a\"" 409 (cons variable (string-join path separator)))))))
410 variable 410
411 (string-join path separator))))))) 411 (filter-map search-path-definition search-paths))
412 412
413(define* (search-path-environment-variables entries profile
414 #:optional (getenv getenv))
415 "Return environment variable definitions that may be needed for the use of
416ENTRIES, a list of manifest entries, in PROFILE. Use GETENV to determine the
417current settings and report only settings not already effective."
413 (let ((search-paths (delete-duplicates 418 (let ((search-paths (delete-duplicates
414 (append-map manifest-entry-search-paths entries)))) 419 (append-map manifest-entry-search-paths entries))))
415 (filter-map search-path-definition search-paths))) 420 (filter-map (match-lambda
421 ((variable . value)
422 (format #f "export ~a=\"~a\"" variable value)))
423 (evaluate-search-paths search-paths profile getenv))))
416 424
417(define (display-search-paths entries profile) 425(define (display-search-paths entries profile)
418 "Display the search path environment variables that may need to be set for 426 "Display the search path environment variables that may need to be set for