2014-04-14 15:26:48 +01:00
|
|
|
{ config, lib, pkgs, ... }:
|
2008-04-01 13:50:47 +01:00
|
|
|
|
2014-04-14 15:26:48 +01:00
|
|
|
with lib;
|
2009-03-06 12:25:57 +00:00
|
|
|
|
|
|
|
let
|
|
|
|
|
2011-07-13 19:24:53 +01:00
|
|
|
cfg = config.services.syslogd;
|
|
|
|
|
2009-03-06 12:25:57 +00:00
|
|
|
syslogConf = pkgs.writeText "syslog.conf" ''
|
2011-07-13 19:24:53 +01:00
|
|
|
${if (cfg.tty != "") then "kern.warning;*.err;authpriv.none /dev/${cfg.tty}" else ""}
|
|
|
|
${cfg.defaultConfig}
|
|
|
|
${cfg.extraConfig}
|
|
|
|
'';
|
2008-05-08 14:47:44 +01:00
|
|
|
|
2011-07-13 19:24:53 +01:00
|
|
|
defaultConf = ''
|
2008-05-08 14:47:44 +01:00
|
|
|
# Send emergency messages to all users.
|
|
|
|
*.emerg *
|
2008-04-01 13:50:47 +01:00
|
|
|
|
2008-05-08 13:27:01 +01:00
|
|
|
# "local1" is used for dhcpd messages.
|
|
|
|
local1.* -/var/log/dhcpd
|
2008-04-01 13:50:47 +01:00
|
|
|
|
2008-05-08 13:27:01 +01:00
|
|
|
mail.* -/var/log/mail
|
2008-04-01 13:50:47 +01:00
|
|
|
|
2008-05-08 13:27:01 +01:00
|
|
|
*.=warning;*.=err -/var/log/warn
|
|
|
|
*.crit /var/log/warn
|
|
|
|
|
|
|
|
*.*;mail.none;local1.none -/var/log/messages
|
2008-04-01 13:50:47 +01:00
|
|
|
'';
|
2011-07-21 08:42:05 +01:00
|
|
|
|
2008-04-01 13:50:47 +01:00
|
|
|
in
|
2006-11-19 20:07:45 +00:00
|
|
|
|
2006-11-19 21:03:22 +00:00
|
|
|
{
|
2009-09-25 20:55:08 +01:00
|
|
|
###### interface
|
|
|
|
|
|
|
|
options = {
|
2011-07-13 19:24:53 +01:00
|
|
|
|
2009-09-25 20:55:08 +01:00
|
|
|
services.syslogd = {
|
|
|
|
|
2012-07-19 17:48:30 +01:00
|
|
|
enable = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
2022-07-28 22:19:15 +01:00
|
|
|
description = lib.mdDoc ''
|
2012-07-19 17:48:30 +01:00
|
|
|
Whether to enable syslogd. Note that systemd also logs
|
|
|
|
syslog messages, so you normally don't need to run syslogd.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2009-09-25 20:55:08 +01:00
|
|
|
tty = mkOption {
|
2013-10-30 10:02:04 +00:00
|
|
|
type = types.str;
|
2009-09-25 20:55:08 +01:00
|
|
|
default = "tty10";
|
2022-07-28 22:19:15 +01:00
|
|
|
description = lib.mdDoc ''
|
2009-09-25 20:55:08 +01:00
|
|
|
The tty device on which syslogd will print important log
|
2011-07-13 19:24:53 +01:00
|
|
|
messages. Leave this option blank to disable tty logging.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
defaultConfig = mkOption {
|
2013-10-30 16:37:45 +00:00
|
|
|
type = types.lines;
|
2011-07-13 19:24:53 +01:00
|
|
|
default = defaultConf;
|
2022-08-28 20:18:44 +01:00
|
|
|
description = lib.mdDoc ''
|
|
|
|
The default {file}`syslog.conf` file configures a
|
2011-07-13 19:24:53 +01:00
|
|
|
fairly standard setup of log files, which can be extended by
|
2022-08-28 20:18:44 +01:00
|
|
|
means of {var}`extraConfig`.
|
2009-03-06 12:25:57 +00:00
|
|
|
'';
|
2009-09-25 20:55:08 +01:00
|
|
|
};
|
2010-03-09 13:31:20 +00:00
|
|
|
|
2011-07-21 08:42:05 +01:00
|
|
|
enableNetworkInput = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
2022-07-28 22:19:15 +01:00
|
|
|
description = lib.mdDoc ''
|
2011-07-21 08:42:05 +01:00
|
|
|
Accept logging through UDP. Option -r of syslogd(8).
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2010-03-09 13:31:20 +00:00
|
|
|
extraConfig = mkOption {
|
2013-10-30 16:37:45 +00:00
|
|
|
type = types.lines;
|
2010-03-09 13:31:20 +00:00
|
|
|
default = "";
|
|
|
|
example = "news.* -/var/log/news";
|
2022-08-28 20:18:44 +01:00
|
|
|
description = lib.mdDoc ''
|
|
|
|
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 19:24:53 +01:00
|
|
|
|
2011-08-08 15:40:16 +01:00
|
|
|
extraParams = mkOption {
|
2015-06-15 17:18:46 +01:00
|
|
|
type = types.listOf types.str;
|
2011-08-08 15:40:16 +01:00
|
|
|
default = [ ];
|
|
|
|
example = [ "-m 0" ];
|
2022-07-28 22:19:15 +01:00
|
|
|
description = lib.mdDoc ''
|
|
|
|
Additional parameters passed to {command}`syslogd`.
|
2011-08-08 15:40:16 +01:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2009-09-25 20:55:08 +01:00
|
|
|
};
|
2011-07-13 19:24:53 +01:00
|
|
|
|
2009-09-25 20:55:08 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
###### implementation
|
|
|
|
|
2012-07-19 17:48:30 +01:00
|
|
|
config = mkIf cfg.enable {
|
|
|
|
|
2016-12-10 12:12:20 +00:00
|
|
|
assertions =
|
|
|
|
[ { assertion = !config.services.rsyslogd.enable;
|
|
|
|
message = "rsyslogd conflicts with syslogd";
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
2012-07-19 17:48:30 +01:00
|
|
|
environment.systemPackages = [ pkgs.sysklogd ];
|
2011-07-13 19:24:53 +01:00
|
|
|
|
2011-08-08 15:40:16 +01:00
|
|
|
services.syslogd.extraParams = optional cfg.enableNetworkInput "-r";
|
|
|
|
|
2012-07-19 22:33:22 +01:00
|
|
|
# FIXME: restarting syslog seems to break journal logging.
|
2013-01-16 11:33:18 +00:00
|
|
|
systemd.services.syslog =
|
2012-10-01 21:27:42 +01:00
|
|
|
{ description = "Syslog Daemon";
|
|
|
|
|
2012-07-19 17:48:30 +01:00
|
|
|
requires = [ "syslog.socket" ];
|
2009-09-25 20:55:08 +01:00
|
|
|
|
2013-03-27 12:58:12 +00:00
|
|
|
wantedBy = [ "multi-user.target" ];
|
2009-11-06 15:46:56 +00:00
|
|
|
|
2012-07-19 17:48:30 +01:00
|
|
|
serviceConfig =
|
2012-10-01 21:27:42 +01:00
|
|
|
{ ExecStart = "${pkgs.sysklogd}/sbin/syslogd ${toString cfg.extraParams} -f ${syslogConf} -n";
|
2012-07-19 17:48:30 +01:00
|
|
|
# Prevent syslogd output looping back through journald.
|
2012-10-01 21:27:42 +01:00
|
|
|
StandardOutput = "null";
|
|
|
|
};
|
2009-09-25 20:55:08 +01:00
|
|
|
};
|
|
|
|
|
2009-03-06 12:25:57 +00:00
|
|
|
};
|
2011-07-13 19:24:53 +01:00
|
|
|
|
2006-11-19 20:07:45 +00:00
|
|
|
}
|