diff --git a/nixos/modules/services/x11/xserver.nix b/nixos/modules/services/x11/xserver.nix
index 9e971671c47..eb8c4c17e98 100644
--- a/nixos/modules/services/x11/xserver.nix
+++ b/nixos/modules/services/x11/xserver.nix
@@ -518,6 +518,19 @@ in
'';
};
+ logFile = mkOption {
+ type = types.nullOr types.str;
+ default = "/dev/null";
+ example = "/var/log/Xorg.0.log";
+ description = ''
+ Controls the file Xorg logs to.
+
+ The default of /dev/null is set so that systemd services (like displayManagers) only log to the journal and don't create their own log files.
+
+ Setting this to null will not pass the -logfile argument to Xorg which allows it to log to its default logfile locations instead (see man Xorg). You probably only want this behaviour when running Xorg manually (e.g. via startx).
+ '';
+ };
+
verbose = mkOption {
type = types.nullOr types.int;
default = 3;
@@ -692,11 +705,10 @@ in
services.xserver.displayManager.xserverArgs =
[ "-config ${configFile}"
"-xkbdir" "${cfg.xkbDir}"
- # Log at the default verbosity level to stderr rather than /var/log/X.*.log.
- "-logfile" "/dev/null"
] ++ optional (cfg.display != null) ":${toString cfg.display}"
++ optional (cfg.tty != null) "vt${toString cfg.tty}"
++ optional (cfg.dpi != null) "-dpi ${toString cfg.dpi}"
+ ++ optional (cfg.logFile != null) "-logfile ${toString cfg.logFile}"
++ optional (cfg.verbose != null) "-verbose ${toString cfg.verbose}"
++ optional (!cfg.enableTCP) "-nolisten tcp"
++ optional (cfg.autoRepeatDelay != null) "-ardelay ${toString cfg.autoRepeatDelay}"