summaryrefslogtreecommitdiff
path: root/guix/scripts/package.scm
diff options
context:
space:
mode:
Diffstat (limited to 'guix/scripts/package.scm')
-rw-r--r--guix/scripts/package.scm20
1 files changed, 17 insertions, 3 deletions
diff --git a/guix/scripts/package.scm b/guix/scripts/package.scm
index f930b00804..1c3209f905 100644
--- a/guix/scripts/package.scm
+++ b/guix/scripts/package.scm
@@ -59,7 +59,8 @@
(define %profile-directory
(string-append %state-directory "/profiles/"
- (or (and=> (getenv "USER")
+ (or (and=> (or (getenv "USER")
+ (getenv "LOGNAME"))
(cut string-append "per-user/" <>))
"default")))
@@ -68,6 +69,17 @@
;; coexist with Nix profiles.
(string-append %profile-directory "/guix-profile"))
+(define (canonicalize-profile profile)
+ "If PROFILE is %USER-PROFILE-DIRECTORY, return %CURRENT-PROFILE. Otherwise
+return PROFILE unchanged. The goal is to treat '-p ~/.guix-profile' as if
+'-p' was omitted." ; see <http://bugs.gnu.org/17939>
+ (if (and %user-profile-directory
+ (string=? (canonicalize-path (dirname profile))
+ (dirname %user-profile-directory))
+ (string=? (basename profile) (basename %user-profile-directory)))
+ %current-profile
+ profile))
+
(define (link-to-empty-profile generation)
"Link GENERATION, a string, to the empty profile."
(let* ((drv (profile-derivation (%store) (manifest '())))
@@ -573,7 +585,7 @@ Install, remove, or upgrade PACKAGES in a single transaction.\n"))
#f)))
(option '(#\p "profile") #t #f
(lambda (opt name arg result arg-handler)
- (values (alist-cons 'profile arg
+ (values (alist-cons 'profile (canonicalize-profile arg)
(alist-delete 'profile result))
#f)))
(option '(#\n "dry-run") #f #f
@@ -797,7 +809,9 @@ more information.~%"))
%profile-directory)
(format (current-error-port)
(_ "Please change the owner of `~a' to user ~s.~%")
- %profile-directory (or (getenv "USER") (getuid)))
+ %profile-directory (or (getenv "USER")
+ (getenv "LOGNAME")
+ (getuid)))
(rtfm))))
(define (process-actions opts)