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.
This commit is contained in:
Ludovic Courtès 2013-05-09 22:58:23 +02:00
parent 9c7dd33a48
commit a81bc5312b
1 changed files with 38 additions and 30 deletions

View File

@ -336,38 +336,46 @@ but ~a is available upstream~%")
PACKAGES in PROFILE. Use GETENV to determine the current settings and report PACKAGES in PROFILE. Use GETENV to determine the current settings and report
only settings not already effective." only settings not already effective."
;; The search path info is not stored in the manifest. Thus, we infer the ;; Prefer ~/.guix-profile to the real profile directory name.
;; search paths from same-named packages found in the distro. (let ((profile (if (and %user-environment-directory
(false-if-exception
(string=? (readlink %user-environment-directory)
profile)))
%user-environment-directory
profile)))
(define package-in-manifest->package ;; The search path info is not stored in the manifest. Thus, we infer the
(match-lambda ;; search paths from same-named packages found in the distro.
((name version _ ...)
(match (append (find-packages-by-name name version)
(find-packages-by-name name))
((p _ ...) p)
(_ #f)))))
(define search-path-definition (define package-in-manifest->package
(match-lambda (match-lambda
(($ <search-path-specification> variable directories separator) ((name version _ ...)
(let ((values (or (and=> (getenv variable) (match (append (find-packages-by-name name version)
(cut string-tokenize* <> separator)) (find-packages-by-name name))
'())) ((p _ ...) p)
(directories (filter file-exists? (_ #f)))))
(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)) (define search-path-definition
(search-paths (delete-duplicates (match-lambda
(append-map package-native-search-paths (($ <search-path-specification> variable directories separator)
packages)))) (let ((values (or (and=> (getenv variable)
(filter-map search-path-definition search-paths))) (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) (define (display-search-paths packages profile)
"Display the search path environment variables that may need to be set for "Display the search path environment variables that may need to be set for
@ -375,7 +383,7 @@ PACKAGES, in the context of PROFILE."
(let ((settings (search-path-environment-variables packages profile))) (let ((settings (search-path-environment-variables packages profile)))
(unless (null? settings) (unless (null? settings)
(format #t (_ "The following environment variable definitions may be needed:~%")) (format #t (_ "The following environment variable definitions may be needed:~%"))
(format #t "~{ ~a~%~}" settings)))) (format #t "~{ ~a~%~}" settings))))
;;; ;;;