2014-04-14 16:26:48 +02:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
pkgs,
|
|
|
|
...
|
|
|
|
}:
|
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" ''
|
2024-08-27 20:43:32 +02:00
|
|
|
${lib.optionalString (cfg.tty != "") "kern.warning;*.err;authpriv.none /dev/${cfg.tty}"}
|
2011-07-13 18:24:53 +00:00
|
|
|
${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 = {
|
|
|
|
|
2024-08-27 20:43:32 +02:00
|
|
|
enable = lib.mkOption {
|
|
|
|
type = lib.types.bool;
|
2012-07-19 12:48:30 -04:00
|
|
|
default = false;
|
|
|
|
description = ''
|
|
|
|
Whether to enable syslogd. Note that systemd also logs
|
|
|
|
syslog messages, so you normally don't need to run syslogd.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2024-08-27 20:43:32 +02:00
|
|
|
tty = lib.mkOption {
|
|
|
|
type = lib.types.str;
|
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.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2024-08-27 20:43:32 +02:00
|
|
|
defaultConfig = lib.mkOption {
|
|
|
|
type = lib.types.lines;
|
2011-07-13 18:24:53 +00:00
|
|
|
default = defaultConf;
|
|
|
|
description = ''
|
|
|
|
The default {file}`syslog.conf` file configures a
|
|
|
|
fairly standard setup of log files, which can be extended by
|
|
|
|
means of {var}`extraConfig`.
|
2009-03-06 12:25:57 +00:00
|
|
|
'';
|
2009-09-25 19:55:08 +00:00
|
|
|
};
|
2010-03-09 13:31:20 +00:00
|
|
|
|
2024-08-27 20:43:32 +02:00
|
|
|
enableNetworkInput = lib.mkOption {
|
|
|
|
type = lib.types.bool;
|
2011-07-21 07:42:05 +00:00
|
|
|
default = false;
|
|
|
|
description = ''
|
|
|
|
Accept logging through UDP. Option -r of syslogd(8).
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2024-08-27 20:43:32 +02:00
|
|
|
extraConfig = lib.mkOption {
|
|
|
|
type = lib.types.lines;
|
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 {file}`syslog.conf`,
|
|
|
|
i.e. the contents of {var}`defaultConfig`.
|
2010-03-09 13:31:20 +00:00
|
|
|
'';
|
|
|
|
};
|
2011-07-13 18:24:53 +00:00
|
|
|
|
2024-08-27 20:43:32 +02:00
|
|
|
extraParams = lib.mkOption {
|
|
|
|
type = lib.types.listOf lib.types.str;
|
2011-08-08 14:40:16 +00:00
|
|
|
default = [ ];
|
|
|
|
example = [ "-m 0" ];
|
|
|
|
description = ''
|
|
|
|
Additional parameters passed to {command}`syslogd`.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
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
|
|
|
|
|
2024-08-27 20:43:32 +02:00
|
|
|
config = lib.mkIf cfg.enable {
|
2012-07-19 12:48:30 -04:00
|
|
|
|
2016-12-10 13:12:20 +01:00
|
|
|
assertions = [
|
|
|
|
{
|
|
|
|
assertion = !config.services.rsyslogd.enable;
|
|
|
|
message = "rsyslogd conflicts with syslogd";
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
2012-07-19 12:48:30 -04:00
|
|
|
environment.systemPackages = [ pkgs.sysklogd ];
|
2011-07-13 18:24:53 +00:00
|
|
|
|
2024-08-27 20:43:32 +02:00
|
|
|
services.syslogd.extraParams = lib.optional cfg.enableNetworkInput "-r";
|
2011-08-08 14:40:16 +00:00
|
|
|
|
2012-07-19 17:33:22 -04:00
|
|
|
# FIXME: restarting syslog seems to break journal logging.
|
2013-01-16 12:33:18 +01:00
|
|
|
systemd.services.syslog = {
|
2012-10-01 16:27:42 -04:00
|
|
|
description = "Syslog Daemon";
|
|
|
|
|
2012-07-19 12:48:30 -04:00
|
|
|
requires = [ "syslog.socket" ];
|
2009-09-25 19:55:08 +00:00
|
|
|
|
2013-03-27 13:58:12 +01:00
|
|
|
wantedBy = [ "multi-user.target" ];
|
2009-11-06 15:46:56 +00:00
|
|
|
|
2012-07-19 12:48:30 -04:00
|
|
|
serviceConfig = {
|
2012-10-01 16:27:42 -04:00
|
|
|
ExecStart = "${pkgs.sysklogd}/sbin/syslogd ${toString cfg.extraParams} -f ${syslogConf} -n";
|
2012-07-19 12:48:30 -04:00
|
|
|
# Prevent syslogd output looping back through journald.
|
2012-10-01 16:27:42 -04:00
|
|
|
StandardOutput = "null";
|
2009-09-25 19:55:08 +00:00
|
|
|
};
|
2024-12-10 20:29:24 +01:00
|
|
|
};
|
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
|
|
|
}
|