2009-09-25 19:55:08 +00:00
|
|
|
{ config, pkgs, ... }:
|
2008-04-01 12:50:47 +00:00
|
|
|
|
2009-09-25 19:55:08 +00:00
|
|
|
with pkgs.lib;
|
2009-03-06 12:25:57 +00:00
|
|
|
|
|
|
|
let
|
|
|
|
|
2011-07-13 18:24:53 +00:00
|
|
|
cfg = config.services.syslogd;
|
|
|
|
|
2009-03-06 12:25:57 +00:00
|
|
|
syslogConf = pkgs.writeText "syslog.conf" ''
|
2011-07-13 18:24:53 +00:00
|
|
|
${if (cfg.tty != "") then "kern.warning;*.err;authpriv.none /dev/${cfg.tty}" else ""}
|
|
|
|
${cfg.defaultConfig}
|
|
|
|
${cfg.extraConfig}
|
|
|
|
'';
|
2008-05-08 13:47:44 +00:00
|
|
|
|
2011-07-13 18:24:53 +00:00
|
|
|
defaultConf = ''
|
2008-05-08 13:47:44 +00:00
|
|
|
# Send emergency messages to all users.
|
|
|
|
*.emerg *
|
2008-04-01 12:50:47 +00:00
|
|
|
|
2008-05-08 12:27:01 +00:00
|
|
|
# "local1" is used for dhcpd messages.
|
|
|
|
local1.* -/var/log/dhcpd
|
2008-04-01 12:50:47 +00:00
|
|
|
|
2008-05-08 12:27:01 +00:00
|
|
|
mail.* -/var/log/mail
|
2008-04-01 12:50:47 +00:00
|
|
|
|
2008-05-08 12:27:01 +00:00
|
|
|
*.=warning;*.=err -/var/log/warn
|
|
|
|
*.crit /var/log/warn
|
|
|
|
|
|
|
|
*.*;mail.none;local1.none -/var/log/messages
|
2008-04-01 12:50:47 +00:00
|
|
|
'';
|
2011-07-21 07:42:05 +00:00
|
|
|
|
2008-04-01 12:50:47 +00:00
|
|
|
in
|
2006-11-19 20:07:45 +00:00
|
|
|
|
2006-11-19 21:03:22 +00:00
|
|
|
{
|
2009-09-25 19:55:08 +00:00
|
|
|
###### interface
|
|
|
|
|
|
|
|
options = {
|
2011-07-13 18:24:53 +00:00
|
|
|
|
2009-09-25 19:55:08 +00:00
|
|
|
services.syslogd = {
|
|
|
|
|
|
|
|
tty = mkOption {
|
2011-07-14 11:35:03 +00:00
|
|
|
type = types.uniq types.string;
|
2009-09-25 19:55:08 +00:00
|
|
|
default = "tty10";
|
|
|
|
description = ''
|
|
|
|
The tty device on which syslogd will print important log
|
2011-07-13 18:24:53 +00:00
|
|
|
messages. Leave this option blank to disable tty logging.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
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>.
|
2009-03-06 12:25:57 +00:00
|
|
|
'';
|
2009-09-25 19:55:08 +00:00
|
|
|
};
|
2010-03-09 13:31:20 +00:00
|
|
|
|
2011-07-21 07:42:05 +00:00
|
|
|
enableNetworkInput = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
|
|
|
description = ''
|
|
|
|
Accept logging through UDP. Option -r of syslogd(8).
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2010-03-09 13:31:20 +00:00
|
|
|
extraConfig = mkOption {
|
2011-07-13 18:24:53 +00:00
|
|
|
type = types.string;
|
2010-03-09 13:31:20 +00:00
|
|
|
default = "";
|
|
|
|
example = "news.* -/var/log/news";
|
|
|
|
description = ''
|
2011-07-13 18:24:53 +00:00
|
|
|
Additional text appended to <filename>syslog.conf</filename>,
|
|
|
|
i.e. the contents of <varname>defaultConfig</varname>.
|
2010-03-09 13:31:20 +00:00
|
|
|
'';
|
|
|
|
};
|
2011-07-13 18:24:53 +00:00
|
|
|
|
2011-08-08 14:40:16 +00:00
|
|
|
extraParams = mkOption {
|
|
|
|
type = types.listOf types.string;
|
|
|
|
default = [ ];
|
|
|
|
example = [ "-m 0" ];
|
|
|
|
description = ''
|
|
|
|
Additional parameters passed to <command>syslogd</command>.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2009-09-25 19:55:08 +00:00
|
|
|
};
|
2011-07-13 18:24:53 +00:00
|
|
|
|
2009-09-25 19:55:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
###### implementation
|
|
|
|
|
|
|
|
config = {
|
2011-07-13 18:24:53 +00:00
|
|
|
|
2011-08-08 14:40:16 +00:00
|
|
|
services.syslogd.extraParams = optional cfg.enableNetworkInput "-r";
|
|
|
|
|
2009-10-12 18:09:34 +00:00
|
|
|
jobs.syslogd =
|
2009-10-12 17:27:57 +00:00
|
|
|
{ description = "Syslog daemon";
|
2009-09-25 19:55:08 +00:00
|
|
|
|
2009-11-06 15:46:56 +00:00
|
|
|
startOn = "started udev";
|
2009-09-25 19:55:08 +00:00
|
|
|
|
|
|
|
environment = { TZ = config.time.timeZone; };
|
|
|
|
|
2009-11-06 15:46:56 +00:00
|
|
|
daemonType = "fork";
|
|
|
|
|
2011-08-08 14:40:16 +00:00
|
|
|
exec = "${pkgs.sysklogd}/sbin/syslogd ${toString cfg.extraParams} -f ${syslogConf}";
|
2009-09-25 19:55:08 +00:00
|
|
|
};
|
|
|
|
|
2009-03-06 12:25:57 +00:00
|
|
|
};
|
2011-07-13 18:24:53 +00:00
|
|
|
|
2006-11-19 20:07:45 +00:00
|
|
|
}
|