summary refs log tree commit diff
path: root/nixos/modules/services/x11/display-managers
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2016-05-24 21:29:22 +0200
committerEelco Dolstra <eelco.dolstra@logicblox.com>2016-05-24 21:46:38 +0200
commitc99608c63808f0fe244fe9619ef6d97bf8a5af6f (patch)
tree8393853ff70d784c1ce96b0c6039fcaea8a9feba /nixos/modules/services/x11/display-managers
parentd84741a4bfb6ed2531ec7154479c147d2c9a737c (diff)
downloadnixlib-c99608c63808f0fe244fe9619ef6d97bf8a5af6f.tar
nixlib-c99608c63808f0fe244fe9619ef6d97bf8a5af6f.tar.gz
nixlib-c99608c63808f0fe244fe9619ef6d97bf8a5af6f.tar.bz2
nixlib-c99608c63808f0fe244fe9619ef6d97bf8a5af6f.tar.lz
nixlib-c99608c63808f0fe244fe9619ef6d97bf8a5af6f.tar.xz
nixlib-c99608c63808f0fe244fe9619ef6d97bf8a5af6f.tar.zst
nixlib-c99608c63808f0fe244fe9619ef6d97bf8a5af6f.zip
Add an option to write the X session log to the journal
... rather than ~/.xsession-errors. It might make sense to make this
the default, in order to eliminate ad hoc, uncentralised, poorly
discoverable log files.
Diffstat (limited to 'nixos/modules/services/x11/display-managers')
-rw-r--r--nixos/modules/services/x11/display-managers/default.nix20
1 files changed, 19 insertions, 1 deletions
diff --git a/nixos/modules/services/x11/display-managers/default.nix b/nixos/modules/services/x11/display-managers/default.nix
index 376f9f4b46b5..09735dac0eb0 100644
--- a/nixos/modules/services/x11/display-managers/default.nix
+++ b/nixos/modules/services/x11/display-managers/default.nix
@@ -32,6 +32,12 @@ let
     ''
       #! ${pkgs.bash}/bin/bash
 
+      ${optionalString cfg.displayManager.logToJournal ''
+        if [ -z "$_DID_SYSTEMD_CAT" ]; then
+          _DID_SYSTEMD_CAT=1 exec ${config.systemd.package}/bin/systemd-cat -t xsession -- "$0" "$sessionType"
+        fi
+      ''}
+
       . /etc/profile
       cd "$HOME"
 
@@ -39,7 +45,7 @@ let
       sessionType="$1"
       if [ "$sessionType" = default ]; then sessionType=""; fi
 
-      ${optionalString (!cfg.displayManager.job.logsXsession) ''
+      ${optionalString (!cfg.displayManager.job.logsXsession && !cfg.displayManager.logToJournal) ''
         exec > ~/.xsession-errors 2>&1
       ''}
 
@@ -83,6 +89,8 @@ let
       # .local/share doesn't exist yet.
       mkdir -p $HOME/.local/share
 
+      unset _DID_SYSTEMD_CAT
+
       ${cfg.displayManager.sessionCommands}
 
       # Allow the user to execute commands at the beginning of the X session.
@@ -278,6 +286,16 @@ in
 
       };
 
+      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.
+        '';
+      };
+
     };
 
   };