1 { config, lib, pkgs, ... }:
4 cfg = config.services.rsyslogd;
6 syslogConf = pkgs.writeText "syslog.conf" ''
8 $SystemLogSocketName /run/systemd/journal/syslog
9 $WorkDirectory /var/spool/rsyslog
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.
45 defaultConfig = lib.mkOption {
46 type = lib.types.lines;
47 default = defaultConf;
49 The default {file}`syslog.conf` file configures a
50 fairly standard setup of log files, which can be extended by
51 means of {var}`extraConfig`.
55 extraConfig = lib.mkOption {
56 type = lib.types.lines;
58 example = "news.* -/var/log/news";
60 Additional text appended to {file}`syslog.conf`,
61 i.e. the contents of {var}`defaultConfig`.
65 extraParams = lib.mkOption {
66 type = lib.types.listOf lib.types.str;
70 Additional parameters passed to {command}`rsyslogd`.
81 config = lib.mkIf cfg.enable {
83 environment.systemPackages = [ pkgs.rsyslog ];
85 systemd.services.syslog =
86 { description = "Syslog Daemon";
88 requires = [ "syslog.socket" ];
90 wantedBy = [ "multi-user.target" ];
93 { ExecStart = "${pkgs.rsyslog}/sbin/rsyslogd ${toString cfg.extraParams} -f ${syslogConf} -n";
94 ExecStartPre = "${pkgs.coreutils}/bin/mkdir -p /var/spool/rsyslog";
95 # Prevent syslogd output looping back through journald.
96 StandardOutput = "null";