nixos/xserver: fix X.org session script logging

This commit is contained in:
rnhmjoj 2017-09-15 00:08:16 +02:00 committed by Robert Helgesson
parent dc5cd7800a
commit 13bb5ff402
No known key found for this signature in database
GPG Key ID: C3DB11069E65DC86
5 changed files with 29 additions and 26 deletions

View File

@ -48,6 +48,10 @@ with lib;
(mkRemovedOptionModule [ "services" "rmilter" "bindInetSockets" ] "Use services.rmilter.bindSocket.* instead") (mkRemovedOptionModule [ "services" "rmilter" "bindInetSockets" ] "Use services.rmilter.bindSocket.* instead")
(mkRemovedOptionModule [ "services" "rmilter" "bindUnixSockets" ] "Use services.rmilter.bindSocket.* instead") (mkRemovedOptionModule [ "services" "rmilter" "bindUnixSockets" ] "Use services.rmilter.bindSocket.* instead")
# Xsession script
(mkRenamedOptionModule [ "services" "xserver" "displayManager" "job" "logsXsession" ] [ "services" "xserver" "displayManager" "job" "logToFile" ])
(mkRenamedOptionModule [ "services" "xserver" "displayManager" "logToJournal" ] [ "services" "xserver" "displayManager" "job" "logToJournal" ])
# Old Grub-related options. # Old Grub-related options.
(mkRenamedOptionModule [ "boot" "initrd" "extraKernelModules" ] [ "boot" "initrd" "kernelModules" ]) (mkRenamedOptionModule [ "boot" "initrd" "extraKernelModules" ] [ "boot" "initrd" "kernelModules" ])
(mkRenamedOptionModule [ "boot" "extraKernelParams" ] [ "boot" "kernelParams" ]) (mkRenamedOptionModule [ "boot" "extraKernelParams" ] [ "boot" "kernelParams" ])

View File

@ -59,12 +59,6 @@ let
# Now it should be safe to assume that the script was called with the # Now it should be safe to assume that the script was called with the
# expected parameters. # expected parameters.
${optionalString cfg.displayManager.logToJournal ''
if [ -z "$_DID_SYSTEMD_CAT" ]; then
_DID_SYSTEMD_CAT=1 exec ${config.systemd.package}/bin/systemd-cat -t xsession -- "$0" "$@"
fi
''}
. /etc/profile . /etc/profile
cd "$HOME" cd "$HOME"
@ -72,16 +66,23 @@ let
sessionType="$1" sessionType="$1"
if [ "$sessionType" = default ]; then sessionType=""; fi if [ "$sessionType" = default ]; then sessionType=""; fi
${optionalString (!cfg.displayManager.job.logsXsession && !cfg.displayManager.logToJournal) ''
exec > ~/.xsession-errors 2>&1
''}
${optionalString cfg.startDbusSession '' ${optionalString cfg.startDbusSession ''
if test -z "$DBUS_SESSION_BUS_ADDRESS"; then if test -z "$DBUS_SESSION_BUS_ADDRESS"; then
exec ${pkgs.dbus.dbus-launch} --exit-with-session "$0" "$sessionType" exec ${pkgs.dbus.dbus-launch} --exit-with-session "$0" "$sessionType"
fi fi
''} ''}
${optionalString cfg.displayManager.job.logToJournal ''
if [ -z "$_DID_SYSTEMD_CAT" ]; then
export _DID_SYSTEMD_CAT=1
exec ${config.systemd.package}/bin/systemd-cat -t xsession "$0" "$sessionType"
fi
''}
${optionalString cfg.displayManager.job.logToFile ''
exec &> >(tee ~/.xsession-errors)
''}
# Start PulseAudio if enabled. # Start PulseAudio if enabled.
${optionalString (config.hardware.pulseaudio.enable) '' ${optionalString (config.hardware.pulseaudio.enable) ''
${optionalString (!config.hardware.pulseaudio.systemWide) ${optionalString (!config.hardware.pulseaudio.systemWide)
@ -306,26 +307,24 @@ in
description = "Additional environment variables needed by the display manager."; description = "Additional environment variables needed by the display manager.";
}; };
logsXsession = mkOption { logToFile = mkOption {
type = types.bool; type = types.bool;
default = false; default = false;
description = '' description = ''
Whether the display manager redirects the Whether the display manager redirects the output of the
output of the session script to session script to <filename>~/.xsession-errors</filename>.
<filename>~/.xsession-errors</filename>.
''; '';
}; };
}; logToJournal = mkOption {
type = types.bool;
default = true;
description = ''
Whether the display manager redirects the output of the
session script to the systemd journal.
'';
};
logToJournal = mkOption {
type = types.bool;
default = true;
description = ''
By default, the stdout/stderr of sessions is written
to <filename>~/.xsession-errors</filename>. When this option
is enabled, it will instead be written to the journal.
'';
}; };
}; };

View File

@ -190,7 +190,7 @@ in
services.xserver.displayManager.slim.enable = false; services.xserver.displayManager.slim.enable = false;
services.xserver.displayManager.job = { services.xserver.displayManager.job = {
logsXsession = true; logToFile = true;
# lightdm relaunches itself via just `lightdm`, so needs to be on the PATH # lightdm relaunches itself via just `lightdm`, so needs to be on the PATH
execCmd = '' execCmd = ''

View File

@ -205,7 +205,7 @@ in
services.xserver.displayManager.slim.enable = false; services.xserver.displayManager.slim.enable = false;
services.xserver.displayManager.job = { services.xserver.displayManager.job = {
logsXsession = true; logToFile = true;
environment = { environment = {
# Load themes from system environment # Load themes from system environment

View File

@ -220,7 +220,7 @@ in
''; '';
services.xserver.displayManager.job = { services.xserver.displayManager.job = {
logsXsession = true; logToFile = true;
execCmd = '' execCmd = ''
${optionalString (cfg.pulseaudio) ${optionalString (cfg.pulseaudio)