git.iko.soy/typeable/nixpkgs
on master help sign in
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.

commitc99608c63808f0fe244fe9619ef6d97bf8a5af6f authorEelco Dolstra <eelco.dolstra@logicblox.com> dateTue 24 May 2016, 21:29 (11 years ago) parentd84741a
2 files changed+21−1
nixos/modules/services/x11/display-managers/default.nix+19−1 nixos/modules/testing/test-instrumentation.nix+2
nixos/modules/services/x11/display-managers/default.nix+19−1
@@ -32,6 +32,12 @@ let
3232 ''
3333 #! ${pkgs.bash}/bin/bash
3434
35+ ${optionalString cfg.displayManager.logToJournal ''
36+ if [ -z "$_DID_SYSTEMD_CAT" ]; then
37+ _DID_SYSTEMD_CAT=1 exec ${config.systemd.package}/bin/systemd-cat -t xsession -- "$0" "$sessionType"
38+ fi
39+ ''}
40+
3541 . /etc/profile
3642 cd "$HOME"
3743
@@ -39,7 +45,7 @@ let
3945 sessionType="$1"
4046 if [ "$sessionType" = default ]; then sessionType=""; fi
4147
42− ${optionalString (!cfg.displayManager.job.logsXsession) ''
48+ ${optionalString (!cfg.displayManager.job.logsXsession && !cfg.displayManager.logToJournal) ''
4349 exec > ~/.xsession-errors 2>&1
4450 ''}
4551
@@ -83,6 +89,8 @@ let
8389 # .local/share doesn't exist yet.
8490 mkdir -p $HOME/.local/share
8591
92+ unset _DID_SYSTEMD_CAT
93+
8694 ${cfg.displayManager.sessionCommands}
8795
8896 # Allow the user to execute commands at the beginning of the X session.
@@ -278,6 +286,16 @@ in
278286
279287 };
280288
289+ logToJournal = mkOption {
290+ type = types.bool;
291+ default = true;
292+ description = ''
293+ By default, the stdout/stderr of sessions is written
294+ to <filename>~/.xsession-errors</filename>. When this option
295+ is enabled, it will instead be written to the journal.
296+ '';
297+ };
298+
281299 };
282300
283301 };
nixos/modules/testing/test-instrumentation.nix+2
@@ -113,6 +113,8 @@ let kernel = config.boot.kernelPackages.kernel; in
113113 # Make it easy to log in as root when running the test interactively.
114114 users.extraUsers.root.initialHashedPassword = mkOverride 150 "";
115115
116+ services.xserver.displayManager.logToJournal = true;
117+
116118 };
117119
118120}