[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
01/06: environment: '--link-profile' uses ~/.guix-profile for environmen
From: |
guix-commits |
Subject: |
01/06: environment: '--link-profile' uses ~/.guix-profile for environment variables. |
Date: |
Mon, 21 Sep 2020 17:38:09 -0400 (EDT) |
civodul pushed a commit to branch master
in repository guix.
commit 9b65281de51bcb56714509524f5ae0731c9b96d0
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Mon Sep 14 22:49:06 2020 +0200
environment: '--link-profile' uses ~/.guix-profile for environment
variables.
Before this patch, we had:
$ guix environment -CP --ad-hoc coreutils
[env]$ echo $PATH
/gnu/store/…-profile/bin
[env]$ echo $GUIX_ENVIRONMENT
/gnu/store/…-profile
After this patch:
$ guix environment -CP --ad-hoc coreutils
[env]$ echo $PATH
/home/ludo/.guix-profile/bin
[env]$ echo $GUIX_ENVIRONMENT
/home/ludo/.guix-profile
* guix/scripts/environment.scm (launch-environment/container): When
LINK-PROFILE? is true, pass ~/.guix-profile as the second argument to
'launch-environment'.
* tests/guix-environment-container.sh: Adjust test accordingly.
* doc/guix.texi (Invoking guix environment): Update accordingly.
---
doc/guix.texi | 5 +++--
guix/scripts/environment.scm | 6 +++++-
tests/guix-environment-container.sh | 10 +++++++---
3 files changed, 15 insertions(+), 6 deletions(-)
diff --git a/doc/guix.texi b/doc/guix.texi
index f7e2204..949551a 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 ad50281..e2e481d 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 45264d4..040f32c 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 \
- branch master updated (a2b2589 -> 92951bf), guix-commits, 2020/09/21
- 01/06: environment: '--link-profile' uses ~/.guix-profile for environment variables.,
guix-commits <=
- 02/06: gnu: gdsl: Replace 'url-fetch' by 'git-fetch'., guix-commits, 2020/09/21
- 03/06: guix: scripts: build: Mention 'PACKAGE' in '--with-source' option., guix-commits, 2020/09/21
- 06/06: bash completion: Complete file names after 'guix package -p'., guix-commits, 2020/09/21
- 04/06: gnu: Add python-rnc2rng., guix-commits, 2020/09/21
- 05/06: gnu: Add python-citeproc-py., guix-commits, 2020/09/21