experiment
This commit is contained in:
parent
fa8692f84c
commit
61475c4779
|
@ -479,7 +479,7 @@ in
|
||||||
if [ -n "$__HM_SESS_VARS_SOURCED" ]; then return; fi
|
if [ -n "$__HM_SESS_VARS_SOURCED" ]; then return; fi
|
||||||
export __HM_SESS_VARS_SOURCED=1
|
export __HM_SESS_VARS_SOURCED=1
|
||||||
|
|
||||||
${config.lib.shell.exportAll cfg.sessionVariables}
|
${config.lib.shell.exportAll' { colonVars = ["NIX_PATH" "PATH"]; } cfg.sessionVariables}
|
||||||
'' + lib.optionalString (cfg.sessionPath != [ ]) ''
|
'' + lib.optionalString (cfg.sessionPath != [ ]) ''
|
||||||
export PATH="$PATH''${PATH:+:}${concatStringsSep ":" cfg.sessionPath}"
|
export PATH="$PATH''${PATH:+:}${concatStringsSep ":" cfg.sessionPath}"
|
||||||
'' + cfg.sessionVariablesExtra;
|
'' + cfg.sessionVariablesExtra;
|
||||||
|
|
|
@ -4,8 +4,25 @@ rec {
|
||||||
# Produces a Bourne shell like variable export statement.
|
# Produces a Bourne shell like variable export statement.
|
||||||
export = n: v: ''export ${n}="${toString v}"'';
|
export = n: v: ''export ${n}="${toString v}"'';
|
||||||
|
|
||||||
|
export' = { colonVars ? [ ] }:
|
||||||
|
n: v:
|
||||||
|
let
|
||||||
|
replaceMatch = match:
|
||||||
|
lib.replaceStrings [ ":\$${match}:" ":\$${match}" "\$${match}:" ] [
|
||||||
|
"\${${match}:+:\$${match}:}"
|
||||||
|
"\${${match}:+:\$${match}}"
|
||||||
|
"\${${match}:+\$${match}:}"
|
||||||
|
];
|
||||||
|
|
||||||
|
mkValue = n: v:
|
||||||
|
if builtins.elem n colonVars then replaceMatch n v else toString v;
|
||||||
|
in ''export ${n}="${mkValue n v}"'';
|
||||||
|
|
||||||
# Given an attribute set containing shell variable names and their
|
# Given an attribute set containing shell variable names and their
|
||||||
# assignment, this function produces a string containing an export
|
# assignment, this function produces a string containing an export
|
||||||
# statement for each set entry.
|
# statement for each set entry.
|
||||||
exportAll = vars: lib.concatStringsSep "\n" (lib.mapAttrsToList export vars);
|
exportAll = vars: lib.concatStringsSep "\n" (lib.mapAttrsToList export vars);
|
||||||
|
|
||||||
|
exportAll' = opts: vars:
|
||||||
|
lib.concatStringsSep "\n" (lib.mapAttrsToList (export' opts) vars);
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,8 +13,8 @@ let
|
||||||
export __HM_SESS_VARS_SOURCED=1
|
export __HM_SESS_VARS_SOURCED=1
|
||||||
|
|
||||||
export LOCALE_ARCHIVE_2_27="${pkgs.glibcLocales}/lib/locale/locale-archive"
|
export LOCALE_ARCHIVE_2_27="${pkgs.glibcLocales}/lib/locale/locale-archive"
|
||||||
export NIX_PATH="testpath=$HOME/testpath:$NIX_PATH"
|
export NIX_PATH="testpath=$HOME/testpath''${NIX_PATH:+:$NIX_PATH}"
|
||||||
export PATH="$PATH:$HOME/bin"
|
export PATH="''${PATH:+$PATH:}$HOME/bin"
|
||||||
export XDG_CACHE_HOME="/home/hm-user/.cache"
|
export XDG_CACHE_HOME="/home/hm-user/.cache"
|
||||||
export XDG_CONFIG_HOME="/home/hm-user/.config"
|
export XDG_CONFIG_HOME="/home/hm-user/.config"
|
||||||
export XDG_DATA_HOME="/home/hm-user/.local/share"
|
export XDG_DATA_HOME="/home/hm-user/.local/share"
|
||||||
|
@ -25,8 +25,8 @@ let
|
||||||
if [ -n "$__HM_SESS_VARS_SOURCED" ]; then return; fi
|
if [ -n "$__HM_SESS_VARS_SOURCED" ]; then return; fi
|
||||||
export __HM_SESS_VARS_SOURCED=1
|
export __HM_SESS_VARS_SOURCED=1
|
||||||
|
|
||||||
export NIX_PATH="testpath=$HOME/testpath:$NIX_PATH"
|
export NIX_PATH="testpath=$HOME/testpath''${NIX_PATH:+:$NIX_PATH}"
|
||||||
export PATH="$PATH:$HOME/bin"
|
export PATH="''${PATH:+$PATH:}$HOME/bin"
|
||||||
export XDG_CACHE_HOME="/home/hm-user/.cache"
|
export XDG_CACHE_HOME="/home/hm-user/.cache"
|
||||||
export XDG_CONFIG_HOME="/home/hm-user/.config"
|
export XDG_CONFIG_HOME="/home/hm-user/.config"
|
||||||
export XDG_DATA_HOME="/home/hm-user/.local/share"
|
export XDG_DATA_HOME="/home/hm-user/.local/share"
|
||||||
|
|
Loading…
Reference in a new issue