diff --git a/modules/xsession.nix b/modules/xsession.nix index 7ba9b54e..6d05d432 100644 --- a/modules/xsession.nix +++ b/modules/xsession.nix @@ -78,6 +78,7 @@ in { importedVariables = mkOption { type = types.listOf (types.strMatching "[a-zA-Z_][a-zA-Z0-9_]*"); + apply = unique; example = [ "GDK_PIXBUF_ICON_LOADER" ]; visible = false; description = '' @@ -184,7 +185,7 @@ in { ${optionalString (cfg.importedVariables != [ ]) ("systemctl --user import-environment " - + toString (unique cfg.importedVariables))} + + escapeShellArgs cfg.importedVariables)} ${cfg.profileExtra} @@ -212,6 +213,10 @@ in { while [ -n "$(systemctl --user --no-legend --state=deactivating list-units)" ]; do sleep 0.5 done + + ${optionalString (cfg.importedVariables != [ ]) + ("systemctl --user unset-environment " + + escapeShellArgs cfg.importedVariables)} ''; }; }; diff --git a/tests/modules/misc/xsession/basic-xprofile-expected.txt b/tests/modules/misc/xsession/basic-xprofile-expected.txt index 282f8f5c..b3d591c2 100644 --- a/tests/modules/misc/xsession/basic-xprofile-expected.txt +++ b/tests/modules/misc/xsession/basic-xprofile-expected.txt @@ -9,7 +9,7 @@ fi # script starts up graphical-session.target. systemctl --user stop graphical-session.target graphical-session-pre.target -systemctl --user import-environment DBUS_SESSION_BUS_ADDRESS DISPLAY SSH_AUTH_SOCK XAUTHORITY XDG_DATA_DIRS XDG_RUNTIME_DIR XDG_SESSION_ID EXTRA_IMPORTED_VARIABLE +systemctl --user import-environment 'DBUS_SESSION_BUS_ADDRESS' 'DISPLAY' 'SSH_AUTH_SOCK' 'XAUTHORITY' 'XDG_DATA_DIRS' 'XDG_RUNTIME_DIR' 'XDG_SESSION_ID' 'EXTRA_IMPORTED_VARIABLE' profile extra commands diff --git a/tests/modules/misc/xsession/basic-xsession-expected.txt b/tests/modules/misc/xsession/basic-xsession-expected.txt index 423e7779..a95bb35a 100644 --- a/tests/modules/misc/xsession/basic-xsession-expected.txt +++ b/tests/modules/misc/xsession/basic-xsession-expected.txt @@ -16,3 +16,5 @@ systemctl --user stop graphical-session-pre.target while [ -n "$(systemctl --user --no-legend --state=deactivating list-units)" ]; do sleep 0.5 done + +systemctl --user unset-environment 'DBUS_SESSION_BUS_ADDRESS' 'DISPLAY' 'SSH_AUTH_SOCK' 'XAUTHORITY' 'XDG_DATA_DIRS' 'XDG_RUNTIME_DIR' 'XDG_SESSION_ID' 'EXTRA_IMPORTED_VARIABLE'