From a81bc5312ba26893c07f9aa432e4cc14e4ceefab Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Thu, 9 May 2013 22:58:23 +0200 Subject: package: Use ~/.guix-profile as the default for --search-paths. * guix/scripts/package.scm (search-path-environment-variables): Prefer %USER-ENVIRONMENT-DIRECTORY when it points to PROFILE. (display-search-paths): Use 3 spaces for indentation. --- guix/scripts/package.scm | 74 +++++++++++++++++++++++++++--------------------- 1 file changed, 41 insertions(+), 33 deletions(-) (limited to 'guix') diff --git a/guix/scripts/package.scm b/guix/scripts/package.scm index c691315253..4018a34ed7 100644 --- a/guix/scripts/package.scm +++ b/guix/scripts/package.scm @@ -336,38 +336,46 @@ (define* (search-path-environment-variables packages profile PACKAGES in PROFILE. Use GETENV to determine the current settings and report only settings not already effective." - ;; The search path info is not stored in the manifest. Thus, we infer the - ;; search paths from same-named packages found in the distro. - - (define package-in-manifest->package - (match-lambda - ((name version _ ...) - (match (append (find-packages-by-name name version) - (find-packages-by-name name)) - ((p _ ...) p) - (_ #f))))) - - (define search-path-definition - (match-lambda - (($ variable directories separator) - (let ((values (or (and=> (getenv variable) - (cut string-tokenize* <> separator)) - '())) - (directories (filter file-exists? - (map (cut string-append profile - "/" <>) - directories)))) - (if (every (cut member <> values) directories) - #f - (format #f "export ~a=\"~a\"" - variable - (string-join directories separator))))))) - - (let* ((packages (filter-map package-in-manifest->package packages)) - (search-paths (delete-duplicates - (append-map package-native-search-paths - packages)))) - (filter-map search-path-definition search-paths))) + ;; Prefer ~/.guix-profile to the real profile directory name. + (let ((profile (if (and %user-environment-directory + (false-if-exception + (string=? (readlink %user-environment-directory) + profile))) + %user-environment-directory + profile))) + + ;; The search path info is not stored in the manifest. Thus, we infer the + ;; search paths from same-named packages found in the distro. + + (define package-in-manifest->package + (match-lambda + ((name version _ ...) + (match (append (find-packages-by-name name version) + (find-packages-by-name name)) + ((p _ ...) p) + (_ #f))))) + + (define search-path-definition + (match-lambda + (($ variable directories separator) + (let ((values (or (and=> (getenv variable) + (cut string-tokenize* <> separator)) + '())) + (directories (filter file-exists? + (map (cut string-append profile + "/" <>) + directories)))) + (if (every (cut member <> values) directories) + #f + (format #f "export ~a=\"~a\"" + variable + (string-join directories separator))))))) + + (let* ((packages (filter-map package-in-manifest->package packages)) + (search-paths (delete-duplicates + (append-map package-native-search-paths + packages)))) + (filter-map search-path-definition search-paths)))) (define (display-search-paths packages profile) "Display the search path environment variables that may need to be set for @@ -375,7 +383,7 @@ (define (display-search-paths packages profile) (let ((settings (search-path-environment-variables packages profile))) (unless (null? settings) (format #t (_ "The following environment variable definitions may be needed:~%")) - (format #t "~{ ~a~%~}" settings)))) + (format #t "~{ ~a~%~}" settings)))) ;;; -- cgit v1.2.3