1 { config, lib, pkgs, ... }:
4 cfg = config.services.syslogd;
6 syslogConf = pkgs.writeText "syslog.conf" ''
7 ${lib.optionalString (cfg.tty != "") "kern.warning;*.err;authpriv.none /dev/${cfg.tty}"}
13 # Send emergency messages to all users.
16 # "local1" is used for dhcpd messages.
17 local1.* -/var/log/dhcpd
21 *.=warning;*.=err -/var/log/warn
24 *.*;mail.none;local1.none -/var/log/messages
36 enable = lib.mkOption {
37 type = lib.types.bool;
40 Whether to enable syslogd. Note that systemd also logs
41 syslog messages, so you normally don't need to run syslogd.
49 The tty device on which syslogd will print important log
50 messages. Leave this option blank to disable tty logging.
54 defaultConfig = lib.mkOption {
55 type = lib.types.lines;
56 default = defaultConf;
58 The default {file}`syslog.conf` file configures a
59 fairly standard setup of log files, which can be extended by
60 means of {var}`extraConfig`.
64 enableNetworkInput = lib.mkOption {
65 type = lib.types.bool;
68 Accept logging through UDP. Option -r of syslogd(8).
72 extraConfig = lib.mkOption {
73 type = lib.types.lines;
75 example = "news.* -/var/log/news";
77 Additional text appended to {file}`syslog.conf`,
78 i.e. the contents of {var}`defaultConfig`.
82 extraParams = lib.mkOption {
83 type = lib.types.listOf lib.types.str;
87 Additional parameters passed to {command}`syslogd`.
98 config = lib.mkIf cfg.enable {
101 [ { assertion = !config.services.rsyslogd.enable;
102 message = "rsyslogd conflicts with syslogd";
106 environment.systemPackages = [ pkgs.sysklogd ];
108 services.syslogd.extraParams = lib.optional cfg.enableNetworkInput "-r";
110 # FIXME: restarting syslog seems to break journal logging.
111 systemd.services.syslog =
112 { description = "Syslog Daemon";
114 requires = [ "syslog.socket" ];
116 wantedBy = [ "multi-user.target" ];
119 { ExecStart = "${pkgs.sysklogd}/sbin/syslogd ${toString cfg.extraParams} -f ${syslogConf} -n";
120 # Prevent syslogd output looping back through journald.
121 StandardOutput = "null";