summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorTomas Volf <~@wolfsden.cz>2026-05-14 21:26:16 +0200
committerMaxim Cournoyer <maxim@guixotic.coop>2026-06-15 10:48:17 +0900
commitd11615f609d2cd58fb1305205a4fa975dc8e4657 (patch)
tree7f282d90f61523ff71c5d342aaa53ed7dd98b5bb /doc
parent2c646830c1de33fba8e761b86a173041150a030c (diff)
environment: Allow setting environment variables with -E.
* guix/scripts/environment.scm (show-environment-options-help) [-E]: Document the change. * guix/scripts/environment.scm (%options) [-E]: If arg contains =, split it and store under 'extra-env. * guix/scripts/environment.scm (launch-environment, launch-environment/fork) (launch-environment/container): Take and use `environment-variables' keyword argument. * guix/scripts/environment.scm (guix-environment*): Process 'environment-variables opts. * guix/profiles.scm (load-profile): Add `environment-variables' keyword argument. * doc/guix.texi (Invoking guix shell): Document the change. * tests/guix-environment.sh (GUIX_TEST_ZZZ): Test it. Change-Id: Ib1db19ef73dda8f561b05731079a96eda076e365 Signed-off-by: Maxim Cournoyer <maxim@guixotic.coop> Modified-by: Maxim Cournoyer <maxim@guixotic.coop>
Diffstat (limited to 'doc')
-rw-r--r--doc/guix.texi17
1 files changed, 12 insertions, 5 deletions
diff --git a/doc/guix.texi b/doc/guix.texi
index c624c497d2a..05eac9bda96 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -6803,20 +6803,26 @@ creating an environment in which search paths only contain package inputs.
6803 6803
6804@item --preserve=@var{regexp} 6804@item --preserve=@var{regexp}
6805@itemx -E @var{regexp} 6805@itemx -E @var{regexp}
6806@itemx -E @var{var}=@var{value}
6806When used alongside @option{--pure}, preserve the environment variables 6807When used alongside @option{--pure}, preserve the environment variables
6807matching @var{regexp}---in other words, put them on a ``white list'' of 6808matching @var{regexp}---in other words, put them on a ``white list'' of
6808environment variables that must be preserved. This option can be repeated 6809environment variables that must be preserved. This option can be
6809several times. 6810repeated several times.
6811
6812When @var{regexp} contains a variable assignment (with a @samp{=}
6813character), the @var{var} environment variable is directly set to the
6814@var{value} in the environment. This is used in the example below to
6815set the number of threads OpenMPI should use:
6810 6816
6811@example 6817@example
6812guix shell --pure --preserve=^SLURM openmpi @dots{} \ 6818guix shell --pure --preserve=^SLURM -E OMP_NUM_THREADS=16 openmpi @dots{} \
6813 -- mpirun @dots{} 6819 -- mpirun @dots{}
6814@end example 6820@end example
6815 6821
6816This example runs @command{mpirun} in a context where the only environment 6822This example runs @command{mpirun} in a context where the only environment
6817variables defined are @env{PATH}, environment variables whose name starts 6823variables defined are @env{PATH}, environment variables whose name starts
6818with @samp{SLURM}, as well as the usual ``precious'' variables (@env{HOME}, 6824with @samp{SLURM}, variable @env{TERM} set to @samp{no=color}, as well as
6819@env{USER}, etc.). 6825the usual ``precious'' variables (@env{HOME}, @env{USER}, etc.).
6820 6826
6821@item --search-paths 6827@item --search-paths
6822Display the environment variable definitions that make up the 6828Display the environment variable definitions that make up the
@@ -7319,6 +7325,7 @@ creating an environment in which search paths only contain package inputs.
7319 7325
7320@item --preserve=@var{regexp} 7326@item --preserve=@var{regexp}
7321@itemx -E @var{regexp} 7327@itemx -E @var{regexp}
7328@itemx -E @var{var}=@var{value}
7322When used alongside @option{--pure}, preserve the environment variables 7329When used alongside @option{--pure}, preserve the environment variables
7323matching @var{regexp}---in other words, put them on a ``white list'' of 7330matching @var{regexp}---in other words, put them on a ``white list'' of
7324environment variables that must be preserved. This option can be repeated 7331environment variables that must be preserved. This option can be repeated