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>
52 lines
1.2 KiB
Nix
52 lines
1.2 KiB
Nix
case:
|
|
{
|
|
config,
|
|
lib,
|
|
options,
|
|
...
|
|
}:
|
|
let
|
|
home = config.home.homeDirectory;
|
|
|
|
dotDir =
|
|
let
|
|
subDir = "subdir/subdir2";
|
|
in
|
|
if case == "absolute" then
|
|
"${home}/${subDir}"
|
|
else if case == "relative" then
|
|
subDir
|
|
else if case == "default" then
|
|
options.programs.zsh.dotDir.default
|
|
else
|
|
abort "Test condition not provided.";
|
|
|
|
absDotDir = lib.optionalString (!lib.hasPrefix home dotDir) "${home}/" + dotDir;
|
|
relDotDir = lib.removePrefix home dotDir;
|
|
in
|
|
{
|
|
config = {
|
|
programs.zsh = {
|
|
enable = true;
|
|
inherit dotDir;
|
|
};
|
|
|
|
test.stubs.zsh = { };
|
|
|
|
nmt.script = lib.concatStringsSep "\n" [
|
|
# check dotDir entrypoint exists
|
|
"assertFileExists home-files/${relDotDir}/.zshenv"
|
|
|
|
# for non-default dotDir only:
|
|
(lib.optionalString (case != "default") ''
|
|
# check .zshenv in homeDirectory sources .zshenv in dotDir
|
|
assertFileRegex home-files/.zshenv \
|
|
"source [\"']\?${absDotDir}/.zshenv[\"']\?"
|
|
|
|
# check that .zshenv in dotDir exports ZDOTDIR
|
|
assertFileRegex home-files/${relDotDir}/.zshenv \
|
|
"export ZDOTDIR=[\"']\?${absDotDir}[\"']\?"
|
|
'')
|
|
];
|
|
};
|
|
}
|