1 { config, pkgs, lib, ... }:
4 cfg = config.services.syslog-ng;
6 syslogngConfig = pkgs.writeText "syslog-ng.conf" ''
11 ctrlSocket = "/run/syslog-ng/syslog-ng.ctl";
12 pidFile = "/run/syslog-ng/syslog-ng.pid";
13 persistFile = "/var/syslog-ng/syslog-ng.persist";
17 "--module-path=${lib.concatStringsSep ":" (["${cfg.package}/lib/syslog-ng"] ++ cfg.extraModulePaths)}"
18 "--cfgfile=${syslogngConfig}"
19 "--control=${ctrlSocket}"
20 "--persist-file=${persistFile}"
21 "--pidfile=${pidFile}"
26 (lib.mkRemovedOptionModule [ "services" "syslog-ng" "serviceName" ] "")
27 (lib.mkRemovedOptionModule [ "services" "syslog-ng" "listenToJournal" ] "")
32 services.syslog-ng = {
33 enable = lib.mkOption {
34 type = lib.types.bool;
37 Whether to enable the syslog-ng daemon.
40 package = lib.mkPackageOption pkgs "syslogng" { };
41 extraModulePaths = lib.mkOption {
42 type = lib.types.listOf lib.types.str;
45 A list of paths that should be included in syslog-ng's
46 `--module-path` option. They should usually
47 end in `/lib/syslog-ng`
50 extraConfig = lib.mkOption {
51 type = lib.types.lines;
54 Configuration added to the end of `syslog-ng.conf`.
57 configHeader = lib.mkOption {
58 type = lib.types.lines;
64 The very first lines of the configuration file. Should usually contain
65 the syslog-ng version header.
71 config = lib.mkIf cfg.enable {
72 systemd.services.syslog-ng = {
73 description = "syslog-ng daemon";
74 preStart = "mkdir -p /{var,run}/syslog-ng";
75 wantedBy = [ "multi-user.target" ];
76 after = [ "multi-user.target" ]; # makes sure hostname etc is set
80 StandardOutput = "null";
81 Restart = "on-failure";
82 ExecStart = "${cfg.package}/sbin/syslog-ng ${lib.concatStringsSep " " syslogngOptions}";
83 ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID";