···55 exec &> >(tee ~/.xsession-errors)
56 ''}
5758- # Tell systemd about our $DISPLAY and $XAUTHORITY.
59- # This is needed by the ssh-agent unit.
60- #
61- # Also tell systemd about the dbus session bus address.
62- # This is required by user units using the session bus.
63- /run/current-system/systemd/bin/systemctl --user import-environment DISPLAY XAUTHORITY DBUS_SESSION_BUS_ADDRESS
64-65 # Load X defaults. This should probably be safe on wayland too.
66 ${xorg.xrdb}/bin/xrdb -merge ${xresourcesXft}
67 if test -e ~/.Xresources; then
···69 elif test -e ~/.Xdefaults; then
70 ${xorg.xrdb}/bin/xrdb -merge ~/.Xdefaults
71 fi
0000007273 # Speed up application start by 50-150ms according to
74 # http://kdemonkey.blogspot.nl/2008/04/magic-trick.html
···289 '';
290 };
29100000000292 job = {
293294 preStart = mkOption {
···392 ];
393394 services.xserver.displayManager.xserverBin = "${xorg.xorgserver.out}/bin/X";
0000000000395396 systemd.user.targets.graphical-session = {
397 unitConfig = {
···55 exec &> >(tee ~/.xsession-errors)
56 ''}
57000000058 # Load X defaults. This should probably be safe on wayland too.
59 ${xorg.xrdb}/bin/xrdb -merge ${xresourcesXft}
60 if test -e ~/.Xresources; then
···62 elif test -e ~/.Xdefaults; then
63 ${xorg.xrdb}/bin/xrdb -merge ~/.Xdefaults
64 fi
65+66+ # Import environment variables into the systemd user environment.
67+ ${optionalString (cfg.displayManager.importedVariables != []) (
68+ "/run/current-system/systemd/bin/systemctl --user import-environment "
69+ + toString (unique cfg.displayManager.importedVariables)
70+ )}
7172 # Speed up application start by 50-150ms according to
73 # http://kdemonkey.blogspot.nl/2008/04/magic-trick.html
···288 '';
289 };
290291+ importedVariables = mkOption {
292+ type = types.listOf (types.strMatching "[a-zA-Z_][a-zA-Z0-9_]*");
293+ visible = false;
294+ description = ''
295+ Environment variables to import into the systemd user environment.
296+ '';
297+ };
298+299 job = {
300301 preStart = mkOption {
···399 ];
400401 services.xserver.displayManager.xserverBin = "${xorg.xorgserver.out}/bin/X";
402+403+ services.xserver.displayManager.importedVariables = [
404+ # This is required by user units using the session bus.
405+ "DBUS_SESSION_BUS_ADDRESS"
406+ # These are needed by the ssh-agent unit.
407+ "DISPLAY"
408+ "XAUTHORITY"
409+ # This is required to specify session within user units (e.g. loginctl lock-session).
410+ "XDG_SESSION_ID"
411+ ];
412413 systemd.user.targets.graphical-session = {
414 unitConfig = {