aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/guix.texi5
-rw-r--r--guix/scripts/environment.scm6
-rw-r--r--tests/guix-environment-container.sh10
3 files changed, 15 insertions, 6 deletions
diff --git a/doc/guix.texi b/doc/guix.texi
index f7e2204b53..949551a163 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -5420,8 +5420,9 @@ device.
@item --link-profile
@itemx -P
For containers, link the environment profile to @file{~/.guix-profile}
-within the container. This is equivalent to running the command
-@samp{ln -s $GUIX_ENVIRONMENT ~/.guix-profile} within the container.
+within the container and set @code{GUIX_ENVIRONMENT} to that.
+This is equivalent to making @file{~/.guix-profile} a symlink to the
+actual profile within the container.
Linking will fail and abort the environment if the directory already
exists, which will certainly be the case if @command{guix environment}
was invoked in the user's home directory.
diff --git a/guix/scripts/environment.scm b/guix/scripts/environment.scm
index ad50281eb2..e2e481dd02 100644
--- a/guix/scripts/environment.scm
+++ b/guix/scripts/environment.scm
@@ -564,7 +564,11 @@ WHILE-LIST."
(primitive-exit/status
;; A container's environment is already purified, so no need to
;; request it be purified again.
- (launch-environment command profile manifest #:pure? #f)))
+ (launch-environment command
+ (if link-profile?
+ (string-append home-dir "/.guix-profile")
+ profile)
+ manifest #:pure? #f)))
#:guest-uid uid
#:guest-gid gid
#:namespaces (if network?
diff --git a/tests/guix-environment-container.sh b/tests/guix-environment-container.sh
index 45264d4978..040f32cce9 100644
--- a/tests/guix-environment-container.sh
+++ b/tests/guix-environment-container.sh
@@ -127,11 +127,15 @@ grep -e "$NIX_STORE_DIR/.*-bash" $tmpdir/mounts # bootstrap bash
rm $tmpdir/mounts
-# Make sure 'GUIX_ENVIRONMENT' is linked to '~/.guix-profile' when requested
+# Make sure 'GUIX_ENVIRONMENT' is set to '~/.guix-profile' when requested
# within a container.
(
- linktest='(exit (string=? (getenv "GUIX_ENVIRONMENT")
-(readlink (string-append (getenv "HOME") "/.guix-profile"))))'
+ linktest='
+(exit (and (string=? (getenv "GUIX_ENVIRONMENT")
+ (string-append (getenv "HOME") "/.guix-profile"))
+ (string-prefix? "'"$NIX_STORE_DIR"'"
+ (readlink (string-append (getenv "HOME")
+ "/.guix-profile")))))'
cd "$tmpdir" \
&& guix environment --bootstrap --container --link-profile \