Skip to content

Commit

Permalink
xsession: cleanup systemd variables (#3636)
Browse files Browse the repository at this point in the history
  • Loading branch information
arcnmx authored May 7, 2023
1 parent e34fbe1 commit 78ceec6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
7 changes: 6 additions & 1 deletion modules/xsession.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ''
Expand Down Expand Up @@ -184,7 +185,7 @@ in {
${optionalString (cfg.importedVariables != [ ])
("systemctl --user import-environment "
+ toString (unique cfg.importedVariables))}
+ escapeShellArgs cfg.importedVariables)}
${cfg.profileExtra}
Expand Down Expand Up @@ -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)}
'';
};
};
Expand Down
2 changes: 1 addition & 1 deletion tests/modules/misc/xsession/basic-xprofile-expected.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 2 additions & 0 deletions tests/modules/misc/xsession/basic-xsession-expected.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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'

0 comments on commit 78ceec6

Please sign in to comment.