From 01ec2aaefeeed45764841cf42e1de56e01209e66 Mon Sep 17 00:00:00 2001 From: Tad Fisher <129148+tadfisher@users.noreply.github.com> Date: Sun, 16 May 2021 14:43:50 -0700 Subject: [PATCH] systemd: revert systemd-environment-generator usage for environment variables (#2001) --- modules/misc/xdg-system-dirs.nix | 6 ++++++ modules/systemd.nix | 5 ----- tests/modules/home-environment/session-variables.nix | 1 - tests/modules/misc/xdg/system-dirs.nix | 4 +++- tests/modules/systemd/session-variables.nix | 5 ----- 5 files changed, 9 insertions(+), 12 deletions(-) diff --git a/modules/misc/xdg-system-dirs.nix b/modules/misc/xdg-system-dirs.nix index d3fad015a..f79ebc55b 100644 --- a/modules/misc/xdg-system-dirs.nix +++ b/modules/misc/xdg-system-dirs.nix @@ -37,11 +37,17 @@ in { config = mkMerge [ (mkIf (cfg.config != [ ]) { + home.sessionVariables.XDG_CONFIG_DIRS = + "${configDirs}\${XDG_CONFIG_DIRS:+:$XDG_CONFIG_DIRS}"; + systemd.user.sessionVariables.XDG_CONFIG_DIRS = "${configDirs}\${XDG_CONFIG_DIRS:+:$XDG_CONFIG_DIRS}"; }) (mkIf (cfg.data != [ ]) { + home.sessionVariables.XDG_DATA_DIRS = + "${dataDirs}\${XDG_DATA_DIRS:+:$XDG_DATA_DIRS}"; + systemd.user.sessionVariables.XDG_DATA_DIRS = "${dataDirs}\${XDG_DATA_DIRS:+:$XDG_DATA_DIRS}"; }) diff --git a/modules/systemd.nix b/modules/systemd.nix index 7c03b5625..e1261b7b4 100644 --- a/modules/systemd.nix +++ b/modules/systemd.nix @@ -333,11 +333,6 @@ in unset systemdStatus '' ); - - # Export environment variables in systemd.user.sessionVariables to login shells. - home.sessionVariablesExtra = optionalString (cfg.sessionVariables != {}) '' - export $(${pkgs.systemd}/lib/systemd/user-environment-generators/30-systemd-environment-d-generator) - ''; }) ]; } diff --git a/tests/modules/home-environment/session-variables.nix b/tests/modules/home-environment/session-variables.nix index 5f52b620e..d939c05eb 100644 --- a/tests/modules/home-environment/session-variables.nix +++ b/tests/modules/home-environment/session-variables.nix @@ -15,7 +15,6 @@ let export XDG_CACHE_HOME="/home/hm-user/.cache" export XDG_CONFIG_HOME="/home/hm-user/.config" export XDG_DATA_HOME="/home/hm-user/.local/share" - export $(${pkgs.systemd}/lib/systemd/user-environment-generators/30-systemd-environment-d-generator) ''; darwinExpected = '' diff --git a/tests/modules/misc/xdg/system-dirs.nix b/tests/modules/misc/xdg/system-dirs.nix index d2913b239..9bfa2ae44 100644 --- a/tests/modules/misc/xdg/system-dirs.nix +++ b/tests/modules/misc/xdg/system-dirs.nix @@ -19,7 +19,9 @@ sessionVarsFile=home-path/etc/profile.d/hm-session-vars.sh assertFileExists $sessionVarsFile assertFileContains $sessionVarsFile \ - 'export $(${pkgs.systemd}/lib/systemd/user-environment-generators/30-systemd-environment-d-generator)' + 'export XDG_CONFIG_DIRS="/etc/xdg:/foo/bar''${XDG_CONFIG_DIRS:+:$XDG_CONFIG_DIRS}"' + assertFileContains $sessionVarsFile \ + 'export XDG_DATA_DIRS="/usr/local/share:/usr/share:/baz/quux''${XDG_DATA_DIRS:+:$XDG_DATA_DIRS}"' ''; }; } diff --git a/tests/modules/systemd/session-variables.nix b/tests/modules/systemd/session-variables.nix index 21d96d449..59d1a4d3a 100644 --- a/tests/modules/systemd/session-variables.nix +++ b/tests/modules/systemd/session-variables.nix @@ -15,11 +15,6 @@ V_int=1 V_str=2 ''} - - sessionVarsFile=home-path/etc/profile.d/hm-session-vars.sh - assertFileExists $sessionVarsFile - assertFileContains $sessionVarsFile \ - 'export $(${pkgs.systemd}/lib/systemd/user-environment-generators/30-systemd-environment-d-generator)' ''; }; }