mirror of
https://github.com/nix-community/home-manager.git
synced 2026-01-12 01:59:37 +08:00
tests/zsh: add xdg dotDir tests
Verify we respect xdg.enable behavior when placing files. Signed-off-by: Austin Horstman <khaneliman12@gmail.com>
This commit is contained in:
@@ -19,12 +19,15 @@
|
||||
zsh-history-path-xdg-variable = import ./history-path.nix "xdg-variable";
|
||||
zsh-history-path-zdotdir-variable = import ./history-path.nix "zdotdir-variable";
|
||||
zsh-history-substring-search = ./history-substring-search.nix;
|
||||
zsh-legacy-warning = ./legacy-warning.nix;
|
||||
zsh-siteFunctions-mkcd = ./siteFunctions-mkcd.nix;
|
||||
zsh-plugins = ./plugins.nix;
|
||||
zsh-prezto = ./prezto.nix;
|
||||
zsh-session-variables = ./session-variables.nix;
|
||||
zsh-smart-formatting = ./smart-formatting.nix;
|
||||
zsh-syntax-highlighting = ./syntax-highlighting.nix;
|
||||
zsh-xdg-default = ./xdg-default.nix;
|
||||
zsh-xdg-disabled = ./xdg-disabled.nix;
|
||||
zsh-zprof = ./zprof.nix;
|
||||
zshrc-contents-priorities = ./zshrc-content-priorities.nix;
|
||||
}
|
||||
|
||||
29
tests/modules/programs/zsh/legacy-warning.nix
Normal file
29
tests/modules/programs/zsh/legacy-warning.nix
Normal file
@@ -0,0 +1,29 @@
|
||||
{
|
||||
config = {
|
||||
programs.zsh.enable = true;
|
||||
xdg.enable = true;
|
||||
|
||||
# We use 25.05 to trigger the legacy warning (since < 26.05)
|
||||
# AND to bypass the global fix in tests/default.nix (which checks for 18.09)
|
||||
home.stateVersion = "25.05";
|
||||
|
||||
nmt.script = ''
|
||||
assertFileExists home-files/.zshrc
|
||||
|
||||
# Verify that the warning is generated
|
||||
# We check the evaluation output for the warning message
|
||||
assertPathNotExists home-files/.config/zsh
|
||||
'';
|
||||
|
||||
test.asserts.warnings.expected = [
|
||||
''
|
||||
The default value of `programs.zsh.dotDir` will change in future versions.
|
||||
You are currently using the legacy default (home directory) because `home.stateVersion` is less than "26.05".
|
||||
To silence this warning and lock in the current behavior, set:
|
||||
programs.zsh.dotDir = config.home.homeDirectory;
|
||||
To adopt the new behavior (XDG config directory), update `home.stateVersion` to "26.05" or set:
|
||||
programs.zsh.dotDir = "''${config.xdg.configHome}/zsh";
|
||||
''
|
||||
];
|
||||
};
|
||||
}
|
||||
21
tests/modules/programs/zsh/xdg-default.nix
Normal file
21
tests/modules/programs/zsh/xdg-default.nix
Normal file
@@ -0,0 +1,21 @@
|
||||
{
|
||||
config = {
|
||||
programs.zsh.enable = true;
|
||||
home.stateVersion = "26.05";
|
||||
xdg.enable = true;
|
||||
|
||||
# With xdg.enable = true and new state version, dotDir should default to XDG config home
|
||||
|
||||
nmt.script = ''
|
||||
assertFileExists home-files/.config/zsh/.zshenv
|
||||
assertFileExists home-files/.config/zsh/.zshrc
|
||||
|
||||
# Verify global .zshenv points to the XDG location
|
||||
assertFileExists home-files/.zshenv
|
||||
assertFileRegex home-files/.zshenv "source /home/hm-user/.config/zsh/.zshenv"
|
||||
|
||||
# Verify ZDOTDIR is exported in the inner .zshenv
|
||||
assertFileRegex home-files/.config/zsh/.zshenv "export ZDOTDIR=\"/home/hm-user/.config/zsh\""
|
||||
'';
|
||||
};
|
||||
}
|
||||
20
tests/modules/programs/zsh/xdg-disabled.nix
Normal file
20
tests/modules/programs/zsh/xdg-disabled.nix
Normal file
@@ -0,0 +1,20 @@
|
||||
{
|
||||
config = {
|
||||
programs.zsh.enable = true;
|
||||
xdg.enable = false;
|
||||
home.stateVersion = "26.05";
|
||||
|
||||
# With xdg.enable = false, dotDir should default to home directory regardless of state version
|
||||
|
||||
nmt.script = ''
|
||||
assertFileExists home-files/.zshenv
|
||||
assertFileExists home-files/.zshrc
|
||||
|
||||
# Should NOT exist in XDG location
|
||||
assertPathNotExists home-files/.config/zsh
|
||||
|
||||
# Verify ZDOTDIR is NOT exported (or points to home if it is, but usually it isn't if dotDir is home)
|
||||
assertFileNotRegex home-files/.zshenv "export ZDOTDIR="
|
||||
'';
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user