1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-27 05:29:46 +01:00

xdg: add XDG_*_HOME variables to systemd.user.sessionVariables (#2790)

Make sure those variables are set in systemd user services.
This mirrors the situation for `XDG_*_DIRS` variables.
This commit is contained in:
Naïm Favier 2022-03-18 03:22:53 +01:00 committed by GitHub
parent e01facc340
commit a4b0a3faa4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 19 additions and 10 deletions

View file

@ -80,18 +80,22 @@ in {
}; };
config = mkMerge [ config = mkMerge [
(mkIf cfg.enable { (let
xdg.cacheHome = mkDefault defaultCacheHome; variables = {
xdg.configHome = mkDefault defaultConfigHome;
xdg.dataHome = mkDefault defaultDataHome;
xdg.stateHome = mkDefault defaultStateHome;
home.sessionVariables = {
XDG_CACHE_HOME = cfg.cacheHome; XDG_CACHE_HOME = cfg.cacheHome;
XDG_CONFIG_HOME = cfg.configHome; XDG_CONFIG_HOME = cfg.configHome;
XDG_DATA_HOME = cfg.dataHome; XDG_DATA_HOME = cfg.dataHome;
XDG_STATE_HOME = cfg.stateHome; XDG_STATE_HOME = cfg.stateHome;
}; };
in mkIf cfg.enable {
xdg.cacheHome = mkDefault defaultCacheHome;
xdg.configHome = mkDefault defaultConfigHome;
xdg.dataHome = mkDefault defaultDataHome;
xdg.stateHome = mkDefault defaultStateHome;
home.sessionVariables = variables;
systemd.user.sessionVariables =
mkIf pkgs.stdenv.hostPlatform.isLinux variables;
}) })
# Legacy non-deterministic setup. # Legacy non-deterministic setup.

View file

@ -11,8 +11,12 @@
assertFileContent $envFile ${ assertFileContent $envFile ${
pkgs.writeText "expected" '' pkgs.writeText "expected" ''
LOCALE_ARCHIVE_2_27=${pkgs.glibcLocales}/lib/locale/locale-archive LOCALE_ARCHIVE_2_27=${pkgs.glibcLocales}/lib/locale/locale-archive
XDG_CACHE_HOME=/home/hm-user/.cache
XDG_CONFIG_DIRS=/etc/xdg:/foo/bar''${XDG_CONFIG_DIRS:+:$XDG_CONFIG_DIRS} XDG_CONFIG_DIRS=/etc/xdg:/foo/bar''${XDG_CONFIG_DIRS:+:$XDG_CONFIG_DIRS}
XDG_CONFIG_HOME=/home/hm-user/.config
XDG_DATA_DIRS=/usr/local/share:/usr/share:/baz/quux''${XDG_DATA_DIRS:+:$XDG_DATA_DIRS} XDG_DATA_DIRS=/usr/local/share:/usr/share:/baz/quux''${XDG_DATA_DIRS:+:$XDG_DATA_DIRS}
XDG_DATA_HOME=/home/hm-user/.local/share
XDG_STATE_HOME=/home/hm-user/.local/state
'' ''
} }

View file

@ -1,3 +0,0 @@
LOCALE_ARCHIVE_2_27=@glibcLocales@/lib/locale/locale-archive
V_int=1
V_str=2

View file

@ -15,6 +15,10 @@
LOCALE_ARCHIVE_2_27=${pkgs.glibcLocales}/lib/locale/locale-archive LOCALE_ARCHIVE_2_27=${pkgs.glibcLocales}/lib/locale/locale-archive
V_int=1 V_int=1
V_str=2 V_str=2
XDG_CACHE_HOME=/home/hm-user/.cache
XDG_CONFIG_HOME=/home/hm-user/.config
XDG_DATA_HOME=/home/hm-user/.local/share
XDG_STATE_HOME=/home/hm-user/.local/state
'' ''
} }
''; '';