2020-04-24 23:36:52 +00:00
|
|
|
{ config, pkgs, lib, ... }:
|
|
|
|
let
|
|
|
|
|
|
|
|
cfg = config.services.syslog-ng;
|
|
|
|
|
|
|
|
syslogngConfig = pkgs.writeText "syslog-ng.conf" ''
|
|
|
|
${cfg.configHeader}
|
|
|
|
${cfg.extraConfig}
|
|
|
|
'';
|
|
|
|
|
|
|
|
ctrlSocket = "/run/syslog-ng/syslog-ng.ctl";
|
|
|
|
pidFile = "/run/syslog-ng/syslog-ng.pid";
|
|
|
|
persistFile = "/var/syslog-ng/syslog-ng.persist";
|
|
|
|
|
|
|
|
syslogngOptions = [
|
|
|
|
"--foreground"
|
2024-09-19 14:19:46 +00:00
|
|
|
"--module-path=${lib.concatStringsSep ":" (["${cfg.package}/lib/syslog-ng"] ++ cfg.extraModulePaths)}"
|
2020-04-24 23:36:52 +00:00
|
|
|
"--cfgfile=${syslogngConfig}"
|
|
|
|
"--control=${ctrlSocket}"
|
|
|
|
"--persist-file=${persistFile}"
|
|
|
|
"--pidfile=${pidFile}"
|
|
|
|
];
|
|
|
|
|
|
|
|
in {
|
|
|
|
imports = [
|
2024-09-19 14:19:46 +00:00
|
|
|
(lib.mkRemovedOptionModule [ "services" "syslog-ng" "serviceName" ] "")
|
|
|
|
(lib.mkRemovedOptionModule [ "services" "syslog-ng" "listenToJournal" ] "")
|
2020-04-24 23:36:52 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
options = {
|
|
|
|
|
|
|
|
services.syslog-ng = {
|
2024-09-19 14:19:46 +00:00
|
|
|
enable = lib.mkOption {
|
|
|
|
type = lib.types.bool;
|
2020-04-24 23:36:52 +00:00
|
|
|
default = false;
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2020-04-24 23:36:52 +00:00
|
|
|
Whether to enable the syslog-ng daemon.
|
|
|
|
'';
|
|
|
|
};
|
2024-09-19 14:19:46 +00:00
|
|
|
package = lib.mkPackageOption pkgs "syslogng" { };
|
|
|
|
extraModulePaths = lib.mkOption {
|
|
|
|
type = lib.types.listOf lib.types.str;
|
2020-04-24 23:36:52 +00:00
|
|
|
default = [];
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2020-04-24 23:36:52 +00:00
|
|
|
A list of paths that should be included in syslog-ng's
|
2022-08-12 12:06:08 +00:00
|
|
|
`--module-path` option. They should usually
|
|
|
|
end in `/lib/syslog-ng`
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
};
|
2024-09-19 14:19:46 +00:00
|
|
|
extraConfig = lib.mkOption {
|
|
|
|
type = lib.types.lines;
|
2020-04-24 23:36:52 +00:00
|
|
|
default = "";
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2022-08-12 12:06:08 +00:00
|
|
|
Configuration added to the end of `syslog-ng.conf`.
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
};
|
2024-09-19 14:19:46 +00:00
|
|
|
configHeader = lib.mkOption {
|
|
|
|
type = lib.types.lines;
|
2020-04-24 23:36:52 +00:00
|
|
|
default = ''
|
2023-11-16 04:20:00 +00:00
|
|
|
@version: 4.4
|
2020-04-24 23:36:52 +00:00
|
|
|
@include "scl.conf"
|
|
|
|
'';
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2020-04-24 23:36:52 +00:00
|
|
|
The very first lines of the configuration file. Should usually contain
|
|
|
|
the syslog-ng version header.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
config = lib.mkIf cfg.enable {
|
2020-04-24 23:36:52 +00:00
|
|
|
systemd.services.syslog-ng = {
|
|
|
|
description = "syslog-ng daemon";
|
|
|
|
preStart = "mkdir -p /{var,run}/syslog-ng";
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
after = [ "multi-user.target" ]; # makes sure hostname etc is set
|
|
|
|
serviceConfig = {
|
|
|
|
Type = "notify";
|
|
|
|
PIDFile = pidFile;
|
|
|
|
StandardOutput = "null";
|
|
|
|
Restart = "on-failure";
|
2024-09-19 14:19:46 +00:00
|
|
|
ExecStart = "${cfg.package}/sbin/syslog-ng ${lib.concatStringsSep " " syslogngOptions}";
|
2020-04-24 23:36:52 +00:00
|
|
|
ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|