1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-11-08 11:36:05 +01:00

zsh: source session variable file directly

Right now we load `hm-session-vars.sh` from
`config.home.profileDirectory`, generally resulting in the following
code being generated in `zshenv`:

```
. "/etc/profiles/per-user/<username>/etc/profile.d/hm-session-vars.sh"
```

This is problematic in a few situations. For example, when entering a
`distrobox` environment I got the following error:

```
/home/<username>/.zshenv:.:2: no such file or directory: /etc/profiles/per-user/<username>/etc/profile.d/hm-session-vars.sh
```

Instead, let's point to the path directly to the `/nix/store` by using
`config.home.sessionVariablesPackage` instead. This is more robust and
it is more consistent with other things we source in ZSH.
This commit is contained in:
Thiago Kenji Okada 2025-09-10 19:08:48 +01:00 committed by Austin Horstman
parent 12fa8548fe
commit 9e0453a9b0
2 changed files with 3 additions and 3 deletions

View file

@ -437,7 +437,7 @@ in
{
home.file."${dotDirRel}/.zshenv".text = ''
# Environment variables
. "${config.home.profileDirectory}/etc/profile.d/hm-session-vars.sh"
. "${config.home.sessionVariablesPackage}/etc/profile.d/hm-session-vars.sh"
# Only source this once
if [[ -z "$__HM_ZSH_SESS_VARS_SOURCED" ]]; then