zsh: improve dotDir handling

Previously, `config.programs.zsh.dotDir` prepended strings with `$HOME`.
This caused issues like nix-community#5100, where `$HOME` is
inconsistently resolved in time for the evaluation of the option. The handling
of this variable is also inconsistent with how paths are handled elsewhere,
including within the same module, where `config.programs.zsh.history.path`
does not mutate the supplied string.

To preserve backwards compatibility, this change prepends
`config.home.homeDirectory` to relative paths, while assigning absolute paths
unchanged. Tests for both cases are added.

Signed-off-by: Austin Horstman <khaneliman12@gmail.com>
This commit is contained in:
Kristopher James Kent (kjkent) 2024-12-31 19:53:48 +00:00 committed by Austin Horstman
parent ef8a9767fc
commit 21399deff2
11 changed files with 173 additions and 82 deletions

View file

@ -23,9 +23,9 @@ in
test.stubs.zsh = { };
nmt.script = ''
assertFileRegex home-files/.zshrc '^path+="$HOME/.zsh/plugins/mockPlugin"$'
assertFileRegex home-files/.zshrc '^fpath+="$HOME/.zsh/plugins/mockPlugin"$'
assertFileRegex home-files/.zshrc '^fpath+=("$HOME/.zsh/plugins/mockPlugin/share/zsh/site-functions" "$HOME/.zsh/plugins/mockPlugin/share/zsh/vendor-completions")$'
assertFileRegex home-files/.zshrc '^path+="/home/hm-user/.zsh/plugins/mockPlugin"$'
assertFileRegex home-files/.zshrc '^fpath+="/home/hm-user/.zsh/plugins/mockPlugin"$'
assertFileRegex home-files/.zshrc '^fpath+=("/home/hm-user/.zsh/plugins/mockPlugin/share/zsh/site-functions" "/home/hm-user/.zsh/plugins/mockPlugin/share/zsh/vendor-completions")$'
'';
};
}