nixpkgs/nixos/modules/services/logging/syslog-ng.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

92 lines
2.4 KiB
Nix
Raw Normal View History

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