hjem/environment: source env file only once
This commit is contained in:
parent
d049c9ce43
commit
55a3c1bce2
1 changed files with 17 additions and 6 deletions
|
@ -23,8 +23,20 @@
|
||||||
in
|
in
|
||||||
attrs:
|
attrs:
|
||||||
writeShellScript "load-env"
|
writeShellScript "load-env"
|
||||||
(concatStringsSep "\n"
|
(
|
||||||
(mapAttrsToList (name: value: "export ${name}=\"${toEnv value}\"") attrs));
|
''
|
||||||
|
# Only execute this file once per shell.
|
||||||
|
if [ -n "$__ETC_PROFILE_SOURCED" ]; then return; fi
|
||||||
|
__ETC_PROFILE_SOURCED=1
|
||||||
|
|
||||||
|
# Prevent this file from being sourced by interactive non-login child shells.
|
||||||
|
export __ETC_PROFILE_DONE=1
|
||||||
|
|
||||||
|
# Session variables
|
||||||
|
''
|
||||||
|
+ (concatStringsSep "\n"
|
||||||
|
(mapAttrsToList (name: value: "export ${name}=\"${toEnv value}\"") attrs))
|
||||||
|
);
|
||||||
in {
|
in {
|
||||||
options.environment = {
|
options.environment = {
|
||||||
sessionVariables = mkOption {
|
sessionVariables = mkOption {
|
||||||
|
@ -36,10 +48,9 @@ in {
|
||||||
};
|
};
|
||||||
description = ''
|
description = ''
|
||||||
A set of environment variables used in the user environment.
|
A set of environment variables used in the user environment.
|
||||||
These variables will be set as systemd user environment
|
These variables will be set using {file}`~/.profile`.
|
||||||
variables, using `~/.profile`. The value of each
|
|
||||||
variable can be either a string or a list of strings. The
|
If a list of strings is used, they will be concatenated with colon
|
||||||
latter is concatenated, interspersed with colon
|
|
||||||
characters.
|
characters.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue