[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
07/07: environment: Define 'GUIX_ENVIRONMENT'.
From: |
Ludovic Court�s |
Subject: |
07/07: environment: Define 'GUIX_ENVIRONMENT'. |
Date: |
Wed, 01 Jul 2015 21:31:19 +0000 |
civodul pushed a commit to branch master
in repository guix.
commit 28de8d258b30f887053d43b2d75a7ed5e2fa2adc
Author: Ludovic Courtès <address@hidden>
Date: Wed Jul 1 14:39:14 2015 +0200
environment: Define 'GUIX_ENVIRONMENT'.
* guix/scripts/environment.scm (create-environment): Define
'GUIX_ENVIRONMENT'.
* doc/guix.texi (Invoking guix environment): Document it.
* gnu/system/shadow.scm (default-skeletons): Adjust 'PS1' depending on
whether
'GUIX_ENVIRONMENT' is defined.
---
doc/guix.texi | 13 +++++++++++++
gnu/system/shadow.scm | 8 +++++++-
guix/scripts/environment.scm | 6 +++++-
3 files changed, 25 insertions(+), 2 deletions(-)
diff --git a/doc/guix.texi b/doc/guix.texi
index a35ea2f..fdd8fdf 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -4146,6 +4146,19 @@ variables in @file{.bashrc}; instead, they should be
defined in
@xref{Bash Startup Files,,, bash, The GNU Bash Reference Manual}, for
details on Bash start-up files.}.
address@hidden GUIX_ENVIRONMENT
address@hidden environment} defines the @code{GUIX_ENVIRONMENT}
+variable in the shell it spaws. This allows users to, say, define a
+specific prompt for development environments in their @file{.bashrc}
+(@pxref{Bash Startup Files,,, bash, The GNU Bash Reference Manual}):
+
address@hidden
+if [ -n "$GUIX_ENVIRONMENT" ]
+then
+ export PS1="\u@@\h \w [dev]\$ "
+fi
address@hidden example
+
Additionally, more than one package may be specified, in which case the
union of the inputs for the given packages are used. For example, the
command below spawns a shell where all of the dependencies of both Guile
diff --git a/gnu/system/shadow.scm b/gnu/system/shadow.scm
index aa97652..ae62292 100644
--- a/gnu/system/shadow.scm
+++ b/gnu/system/shadow.scm
@@ -153,7 +153,13 @@ then
source /etc/profile
fi
-PS1='address@hidden \\w\\$ '
+# Adjust the prompt depending on whether we're in 'guix environment'.
+if [ -n \"$GUIX_ENVIRONMENT\" ]
+then
+ export PS1='address@hidden \\w\\ [env]$ '
+else
+ export PS1='address@hidden \\w\\$ '
+fi
alias ls='ls -p --color'
alias ll='ls -l'\n"))
(zlogin (text-file "zlogin" "\
diff --git a/guix/scripts/environment.scm b/guix/scripts/environment.scm
index 00c4df7..c6cac46 100644
--- a/guix/scripts/environment.scm
+++ b/guix/scripts/environment.scm
@@ -78,7 +78,11 @@ search paths."
(if (and current (not pure?))
(string-append value separator current)
value)))))
- (evaluate-input-search-paths inputs paths)))
+ (evaluate-input-search-paths inputs paths))
+
+ ;; Give users a way to know that they're in 'guix environment', so they can
+ ;; adjust 'PS1' accordingly, for instance.
+ (setenv "GUIX_ENVIRONMENT" "t"))
(define (show-search-paths inputs search-paths pure?)
"Display SEARCH-PATHS applied to the packages specified by INPUTS, a list of
- branch master updated (d690279 -> 28de8d2), Ludovic Court�s, 2015/07/01
- 01/07: tests: Add tests for 'guix environment'., Ludovic Court�s, 2015/07/01
- 03/07: environment: Add --system., Ludovic Court�s, 2015/07/01
- 02/07: environment: Add only the specified outputs of the dependencies., Ludovic Court�s, 2015/07/01
- 05/07: environment: Improve error reporting for '-l'., Ludovic Court�s, 2015/07/01
- 04/07: environment: For --ad-hoc, allow users to specify an output., Ludovic Court�s, 2015/07/01
- 06/07: doc: Mention .bashrc vs. .bash_profile for 'guix environment'., Ludovic Court�s, 2015/07/01
- 07/07: environment: Define 'GUIX_ENVIRONMENT'.,
Ludovic Court�s <=