···5555 exec &> >(tee ~/.xsession-errors)
5656 ''}
57575858- # Tell systemd about our $DISPLAY and $XAUTHORITY.
5959- # This is needed by the ssh-agent unit.
6060- #
6161- # Also tell systemd about the dbus session bus address.
6262- # This is required by user units using the session bus.
6363- /run/current-system/systemd/bin/systemctl --user import-environment DISPLAY XAUTHORITY DBUS_SESSION_BUS_ADDRESS
6464-6558 # Load X defaults. This should probably be safe on wayland too.
6659 ${xorg.xrdb}/bin/xrdb -merge ${xresourcesXft}
6760 if test -e ~/.Xresources; then
···6962 elif test -e ~/.Xdefaults; then
7063 ${xorg.xrdb}/bin/xrdb -merge ~/.Xdefaults
7164 fi
6565+6666+ # Import environment variables into the systemd user environment.
6767+ ${optionalString (cfg.displayManager.importedVariables != []) (
6868+ "/run/current-system/systemd/bin/systemctl --user import-environment "
6969+ + toString (unique cfg.displayManager.importedVariables)
7070+ )}
72717372 # Speed up application start by 50-150ms according to
7473 # http://kdemonkey.blogspot.nl/2008/04/magic-trick.html
···289288 '';
290289 };
291290291291+ importedVariables = mkOption {
292292+ type = types.listOf (types.strMatching "[a-zA-Z_][a-zA-Z0-9_]*");
293293+ visible = false;
294294+ description = ''
295295+ Environment variables to import into the systemd user environment.
296296+ '';
297297+ };
298298+292299 job = {
293300294301 preStart = mkOption {
···392399 ];
393400394401 services.xserver.displayManager.xserverBin = "${xorg.xorgserver.out}/bin/X";
402402+403403+ services.xserver.displayManager.importedVariables = [
404404+ # This is required by user units using the session bus.
405405+ "DBUS_SESSION_BUS_ADDRESS"
406406+ # These are needed by the ssh-agent unit.
407407+ "DISPLAY"
408408+ "XAUTHORITY"
409409+ # This is required to specify session within user units (e.g. loginctl lock-session).
410410+ "XDG_SESSION_ID"
411411+ ];
395412396413 systemd.user.targets.graphical-session = {
397414 unitConfig = {