diff options
author | Rob Vermaas <rob.vermaas@gmail.com> | 2013-03-15 12:55:49 +0100 |
---|---|---|
committer | Rob Vermaas <rob.vermaas@gmail.com> | 2013-03-15 12:55:49 +0100 |
commit | 9a9b53aa9f3864211918d80b6c682e1df1bdd705 (patch) | |
tree | 8664c9b7688e4427a81772adb99bb8b7f36f3b68 | |
parent | f3d063f3983e593559ed7cbaa57fb886025eb270 (diff) | |
download | nixpkgs-9a9b53aa9f3864211918d80b6c682e1df1bdd705.tar nixpkgs-9a9b53aa9f3864211918d80b6c682e1df1bdd705.tar.gz nixpkgs-9a9b53aa9f3864211918d80b6c682e1df1bdd705.tar.bz2 nixpkgs-9a9b53aa9f3864211918d80b6c682e1df1bdd705.tar.lz nixpkgs-9a9b53aa9f3864211918d80b6c682e1df1bdd705.tar.xz nixpkgs-9a9b53aa9f3864211918d80b6c682e1df1bdd705.tar.zst nixpkgs-9a9b53aa9f3864211918d80b6c682e1df1bdd705.zip |
Add module for rsyslog. Although rsyslog is supposed to be a drop-in
replacement for sysklogd, it lacks some support for certain arguments used in the default syslog module of NixOS.
-rw-r--r-- | modules/module-list.nix | 1 | ||||
-rw-r--r-- | modules/services/logging/rsyslogd.nix | 105 |
2 files changed, 106 insertions, 0 deletions
diff --git a/modules/module-list.nix b/modules/module-list.nix index 76101dcb7c8..f4cefaebce2 100644 --- a/modules/module-list.nix +++ b/modules/module-list.nix @@ -86,6 +86,7 @@ ./services/logging/logrotate.nix ./services/logging/logstash.nix ./services/logging/syslogd.nix + ./services/logging/rsyslogd.nix ./services/mail/dovecot.nix ./services/mail/freepops.nix ./services/mail/mail.nix diff --git a/modules/services/logging/rsyslogd.nix b/modules/services/logging/rsyslogd.nix new file mode 100644 index 00000000000..550156a113e --- /dev/null +++ b/modules/services/logging/rsyslogd.nix @@ -0,0 +1,105 @@ +{ config, pkgs, ... }: + +with pkgs.lib; + +let + + cfg = config.services.rsyslogd; + + syslogConf = pkgs.writeText "syslog.conf" '' + $ModLoad imuxsock + $SystemLogSocketName /run/systemd/journal/syslog + + ${cfg.defaultConfig} + ${cfg.extraConfig} + ''; + + defaultConf = '' + # "local1" is used for dhcpd messages. + local1.* -/var/log/dhcpd + + mail.* -/var/log/mail + + *.=warning;*.=err -/var/log/warn + *.crit /var/log/warn + + *.*;mail.none;local1.none -/var/log/messages + ''; + +in + +{ + ###### interface + + options = { + + services.rsyslogd = { + + enable = mkOption { + type = types.bool; + default = false; + description = '' + Whether to enable syslogd. Note that systemd also logs + syslog messages, so you normally don't need to run syslogd. + ''; + }; + + defaultConfig = mkOption { + type = types.string; + default = defaultConf; + description = '' + The default <filename>syslog.conf</filename> file configures a + fairly standard setup of log files, which can be extended by + means of <varname>extraConfig</varname>. + ''; + }; + + extraConfig = mkOption { + type = types.string; + default = ""; + example = "news.* -/var/log/news"; + description = '' + Additional text appended to <filename>syslog.conf</filename>, + i.e. the contents of <varname>defaultConfig</varname>. + ''; + }; + + extraParams = mkOption { + type = types.listOf types.string; + default = [ ]; + example = [ "-m 0" ]; + description = '' + Additional parameters passed to <command>rsyslogd</command>. + ''; + }; + + }; + + }; + + + ###### implementation + + config = mkIf cfg.enable { + + environment.systemPackages = [ pkgs.rsyslog ]; + + systemd.services.syslog = + { description = "Syslog Daemon"; + + requires = [ "syslog.socket" ]; + + wantedBy = [ "multi-user.target" "syslog.target" ]; + + environment.TZ = config.time.timeZone; + + serviceConfig = + { ExecStart = "${pkgs.rsyslog}/sbin/rsyslogd ${toString cfg.extraParams} -f ${syslogConf} -n"; + # Prevent syslogd output looping back through journald. + StandardOutput = "null"; + }; + }; + + }; + +} |