xdg.userDirs: add a setSessionVariables option

It defaults to `true` to maintain the current behavior.

This is conditionalized on 26.05, so in future `setSessionVariables` will
default to `false`.
This commit is contained in:
Greg Pfeil 2025-10-07 22:39:05 -06:00 committed by Austin Horstman
parent 83cc9d32e3
commit db9044b119

View file

@ -110,6 +110,26 @@ in
};
createDirectories = lib.mkEnableOption "automatic creation of the XDG user directories";
setSessionVariables = mkOption {
type = with types; bool;
default = lib.versionOlder config.home.stateVersion "26.05";
defaultText = literalExpression ''
lib.versionOlder config.home.stateVersion "26.05"
'';
description = ''
Whether to set the XDG user dir environment variables, like
`XDG_DESKTOP_DIR`.
::: {.note}
The recommended way to get these values is via the `xdg-user-dir`
command or by processing `$XDG_CONFIG_HOME/user-dirs.dirs` directly in
your application.
:::
This defaults to `true` for state version < 26.05 and `false` otherwise.
'';
};
};
config =
@ -139,7 +159,7 @@ in
home.packages = lib.mkIf (cfg.package != null) [ cfg.package ];
home.sessionVariables = directories;
home.sessionVariables = lib.mkIf cfg.setSessionVariables directories;
home.activation.createXdgUserDirectories = lib.mkIf cfg.createDirectories (
let