diff --git a/tests/modules/programs/zsh/default.nix b/tests/modules/programs/zsh/default.nix index 95eb564b6..45adf1bd9 100644 --- a/tests/modules/programs/zsh/default.nix +++ b/tests/modules/programs/zsh/default.nix @@ -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; } diff --git a/tests/modules/programs/zsh/legacy-warning.nix b/tests/modules/programs/zsh/legacy-warning.nix new file mode 100644 index 000000000..35aa15ea4 --- /dev/null +++ b/tests/modules/programs/zsh/legacy-warning.nix @@ -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"; + '' + ]; + }; +} diff --git a/tests/modules/programs/zsh/xdg-default.nix b/tests/modules/programs/zsh/xdg-default.nix new file mode 100644 index 000000000..c4f354257 --- /dev/null +++ b/tests/modules/programs/zsh/xdg-default.nix @@ -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\"" + ''; + }; +} diff --git a/tests/modules/programs/zsh/xdg-disabled.nix b/tests/modules/programs/zsh/xdg-disabled.nix new file mode 100644 index 000000000..019dfb32c --- /dev/null +++ b/tests/modules/programs/zsh/xdg-disabled.nix @@ -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=" + ''; + }; +}