2014-04-14 14:26:48 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
2013-03-15 11:55:49 +00:00
|
|
|
|
2014-04-14 14:26:48 +00:00
|
|
|
with lib;
|
2013-03-15 11:55:49 +00:00
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
cfg = config.services.rsyslogd;
|
|
|
|
|
|
|
|
syslogConf = pkgs.writeText "syslog.conf" ''
|
|
|
|
$ModLoad imuxsock
|
|
|
|
$SystemLogSocketName /run/systemd/journal/syslog
|
2013-03-17 20:36:25 +00:00
|
|
|
$WorkDirectory /var/spool/rsyslog
|
2013-03-15 11:55:49 +00:00
|
|
|
|
|
|
|
${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 {
|
2015-06-15 16:18:46 +00:00
|
|
|
type = types.listOf types.str;
|
2013-03-15 11:55:49 +00:00
|
|
|
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" ];
|
|
|
|
|
2013-03-27 12:58:12 +00:00
|
|
|
wantedBy = [ "multi-user.target" ];
|
2013-03-15 11:55:49 +00:00
|
|
|
|
|
|
|
serviceConfig =
|
|
|
|
{ ExecStart = "${pkgs.rsyslog}/sbin/rsyslogd ${toString cfg.extraParams} -f ${syslogConf} -n";
|
2013-03-17 20:36:25 +00:00
|
|
|
ExecStartPre = "${pkgs.coreutils}/bin/mkdir -p /var/spool/rsyslog";
|
2013-03-15 11:55:49 +00:00
|
|
|
# Prevent syslogd output looping back through journald.
|
|
|
|
StandardOutput = "null";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|