1 { config, pkgs, lib, ... }:
7 cfg = config.services.syslog-ng;
9 syslogngConfig = pkgs.writeText "syslog-ng.conf" ''
14 ctrlSocket = "/run/syslog-ng/syslog-ng.ctl";
15 pidFile = "/run/syslog-ng/syslog-ng.pid";
16 persistFile = "/var/syslog-ng/syslog-ng.persist";
20 "--module-path=${concatStringsSep ":" (["${cfg.package}/lib/syslog-ng"] ++ cfg.extraModulePaths)}"
21 "--cfgfile=${syslogngConfig}"
22 "--control=${ctrlSocket}"
23 "--persist-file=${persistFile}"
24 "--pidfile=${pidFile}"
29 (mkRemovedOptionModule [ "services" "syslog-ng" "serviceName" ] "")
30 (mkRemovedOptionModule [ "services" "syslog-ng" "listenToJournal" ] "")
35 services.syslog-ng = {
39 description = lib.mdDoc ''
40 Whether to enable the syslog-ng daemon.
45 default = pkgs.syslogng;
46 defaultText = literalExpression "pkgs.syslogng";
47 description = lib.mdDoc ''
48 The package providing syslog-ng binaries.
51 extraModulePaths = mkOption {
52 type = types.listOf types.str;
54 description = lib.mdDoc ''
55 A list of paths that should be included in syslog-ng's
56 `--module-path` option. They should usually
57 end in `/lib/syslog-ng`
60 extraConfig = mkOption {
63 description = lib.mdDoc ''
64 Configuration added to the end of `syslog-ng.conf`.
67 configHeader = mkOption {
73 description = lib.mdDoc ''
74 The very first lines of the configuration file. Should usually contain
75 the syslog-ng version header.
81 config = mkIf cfg.enable {
82 systemd.services.syslog-ng = {
83 description = "syslog-ng daemon";
84 preStart = "mkdir -p /{var,run}/syslog-ng";
85 wantedBy = [ "multi-user.target" ];
86 after = [ "multi-user.target" ]; # makes sure hostname etc is set
90 StandardOutput = "null";
91 Restart = "on-failure";
92 ExecStart = "${cfg.package}/sbin/syslog-ng ${concatStringsSep " " syslogngOptions}";
93 ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID";