@@ -59,12 +59,6 @@ let
5959 # Now it should be safe to assume that the script was called with the
6060 # expected parameters.
6161
62− ${optionalString cfg.displayManager.logToJournal ''
63− if [ -z "$_DID_SYSTEMD_CAT" ]; then
64− _DID_SYSTEMD_CAT=1 exec ${config.systemd.package}/bin/systemd-cat -t xsession -- "$0" "$@"
65− fi
66− ''}
67−
6862 . /etc/profile
6963 cd "$HOME"
7064
@@ -72,16 +66,23 @@ let
7266 sessionType="$1"
7367 if [ "$sessionType" = default ]; then sessionType=""; fi
7468
75− ${optionalString (!cfg.displayManager.job.logsXsession && !cfg.displayManager.logToJournal) ''
76− exec > ~/.xsession-errors 2>&1
77− ''}
78−
7969 ${optionalString cfg.startDbusSession ''
8070 if test -z "$DBUS_SESSION_BUS_ADDRESS"; then
8171 exec ${pkgs.dbus.dbus-launch} --exit-with-session "$0" "$sessionType"
8272 fi
8373 ''}
8474
75+ ${optionalString cfg.displayManager.job.logToJournal ''
76+ if [ -z "$_DID_SYSTEMD_CAT" ]; then
77+ export _DID_SYSTEMD_CAT=1
78+ exec ${config.systemd.package}/bin/systemd-cat -t xsession "$0" "$sessionType"
79+ fi
80+ ''}
81+
82+ ${optionalString cfg.displayManager.job.logToFile ''
83+ exec &> >(tee ~/.xsession-errors)
84+ ''}
85+
8586 # Start PulseAudio if enabled.
8687 ${optionalString (config.hardware.pulseaudio.enable) ''
8788 ${optionalString (!config.hardware.pulseaudio.systemWide)
@@ -306,26 +307,24 @@ in
306307 description = "Additional environment variables needed by the display manager.";
307308 };
308309
309− logsXsession = mkOption {
310+ logToFile = mkOption {
310311 type = types.bool;
311312 default = false;
312313 description = ''
313− Whether the display manager redirects the
314− output of the session script to
315− <filename>~/.xsession-errors</filename>.
314+ Whether the display manager redirects the output of the
315+ session script to <filename>~/.xsession-errors</filename>.
316316 '';
317317 };
318318
319− };
319+ logToJournal = mkOption {
320+ type = types.bool;
321+ default = true;
322+ description = ''
323+ Whether the display manager redirects the output of the
324+ session script to the systemd journal.
325+ '';
326+ };
320327
321− logToJournal = mkOption {
322− type = types.bool;
323− default = true;
324− description = ''
325− By default, the stdout/stderr of sessions is written
326− to <filename>~/.xsession-errors</filename>. When this option
327− is enabled, it will instead be written to the journal.
328− '';
329328 };
330329
331330 };