mirror of
https://github.com/nix-community/home-manager.git
synced 2026-06-05 21:02:51 +00:00
zsh: load session vars from zprofile for login shells
Zsh reads .zshenv before system login startup files. On NixOS and macOS those later files can replace or reorder PATH, so home.sessionPath entries loaded from .zshenv may disappear or move behind system paths. Keep .zshenv coverage for non-login shells, but source Home Manager session variables from .zprofile for login shells so PATH-like values are applied after system login setup. Fixes #2991
This commit is contained in:
@@ -18,5 +18,7 @@
|
||||
nmt.script = ''
|
||||
assertFileExists home-files/.zshenv
|
||||
assertFileContent $(normalizeStorePaths home-files/.zshenv) ${./session-variables.zshenv}
|
||||
assertFileExists home-files/.zprofile
|
||||
assertFileContent $(normalizeStorePaths home-files/.zprofile) ${./session-variables.zprofile}
|
||||
'';
|
||||
}
|
||||
|
||||
13
tests/modules/programs/zsh/session-variables.zprofile
Normal file
13
tests/modules/programs/zsh/session-variables.zprofile
Normal file
@@ -0,0 +1,13 @@
|
||||
# Environment variables
|
||||
. "/nix/store/00000000000000000000000000000000-hm-session-vars.sh/etc/profile.d/hm-session-vars.sh"
|
||||
|
||||
# Only source this once
|
||||
if [[ -z "${__HM_ZSH_SESS_VARS_SOURCED-}" ]]; then
|
||||
export __HM_ZSH_SESS_VARS_SOURCED=1
|
||||
export IS_EMPTY=""
|
||||
export IS_FALSE=false
|
||||
export IS_TRUE=true
|
||||
export PATH="$HOME/bin:$PATH"
|
||||
export V1="v1"
|
||||
export V2="v2-v1"
|
||||
fi
|
||||
@@ -1,13 +1,15 @@
|
||||
# Environment variables
|
||||
. "/nix/store/00000000000000000000000000000000-hm-session-vars.sh/etc/profile.d/hm-session-vars.sh"
|
||||
if [[ ! -o login ]]; then
|
||||
# Environment variables
|
||||
. "/nix/store/00000000000000000000000000000000-hm-session-vars.sh/etc/profile.d/hm-session-vars.sh"
|
||||
|
||||
# Only source this once
|
||||
if [[ -z "${__HM_ZSH_SESS_VARS_SOURCED-}" ]]; then
|
||||
export __HM_ZSH_SESS_VARS_SOURCED=1
|
||||
export IS_EMPTY=""
|
||||
export IS_FALSE=false
|
||||
export IS_TRUE=true
|
||||
export PATH="$HOME/bin:$PATH"
|
||||
export V1="v1"
|
||||
export V2="v2-v1"
|
||||
# Only source this once
|
||||
if [[ -z "${__HM_ZSH_SESS_VARS_SOURCED-}" ]]; then
|
||||
export __HM_ZSH_SESS_VARS_SOURCED=1
|
||||
export IS_EMPTY=""
|
||||
export IS_FALSE=false
|
||||
export IS_TRUE=true
|
||||
export PATH="$HOME/bin:$PATH"
|
||||
export V1="v1"
|
||||
export V2="v2-v1"
|
||||
fi
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user