xdg-user-dirs: warn on setSessionVariables default change

Switch xdg.userDirs.setSessionVariables to the shared state-version default helper so older configurations get an explicit warning before the legacy default is removed.

Add focused tests for the legacy and current branches to verify that the session variable exports remain enabled before 26.05 and are disabled by default starting at 26.05.

Signed-off-by: Austin Horstman <khaneliman12@gmail.com>
This commit is contained in:
Austin Horstman 2026-03-13 13:29:21 -05:00
parent db91cbf795
commit acf65ad748
4 changed files with 37 additions and 4 deletions

View file

@ -136,10 +136,21 @@ in
setSessionVariables = mkOption {
type = with types; bool;
default = lib.versionOlder config.home.stateVersion "26.05";
defaultText = literalExpression ''
lib.versionOlder config.home.stateVersion "26.05"
'';
inherit
(lib.hm.deprecations.mkStateVersionOptionDefault {
inherit (config.home) stateVersion;
since = "26.05";
optionPath = [
"xdg"
"userDirs"
"setSessionVariables"
];
legacy.value = true;
current.value = false;
})
default
defaultText
;
description = ''
Whether to set the XDG user dir environment variables, like
`XDG_DESKTOP_DIR`.

View file

@ -7,4 +7,6 @@
xdg-user-dirs-mixed = ./user-dirs-mixed.nix;
xdg-user-dirs-null = ./user-dirs-null.nix;
xdg-user-dirs-short = ./user-dirs-short.nix;
xdg-user-dirs-session-vars-legacy = ./user-dirs-session-vars-legacy.nix;
xdg-user-dirs-session-vars-current = ./user-dirs-session-vars-current.nix;
}

View file

@ -0,0 +1,10 @@
{
home.stateVersion = "26.05";
xdg.userDirs.enable = true;
nmt.script = ''
assertFileNotRegex home-path/etc/profile.d/hm-session-vars.sh \
'^export XDG_DESKTOP_DIR='
'';
}

View file

@ -0,0 +1,10 @@
{
home.stateVersion = "25.11";
xdg.userDirs.enable = true;
nmt.script = ''
assertFileContains home-path/etc/profile.d/hm-session-vars.sh \
'export XDG_DESKTOP_DIR="/home/hm-user/Desktop"'
'';
}