2e751c0772
the conversion procedure is simple: - find all things that look like options, ie calls to either `mkOption` or `lib.mkOption` that take an attrset. remember the attrset as the option - for all options, find a `description` attribute who's value is not a call to `mdDoc` or `lib.mdDoc` - textually convert the entire value of the attribute to MD with a few simple regexes (the set from mdize-module.sh) - if the change produced a change in the manual output, discard - if the change kept the manual unchanged, add some text to the description to make sure we've actually found an option. if the manual changes this time, keep the converted description this procedure converts 80% of nixos options to markdown. around 2000 options remain to be inspected, but most of those fail the "does not change the manual output check": currently the MD conversion process does not faithfully convert docbook tags like <code> and <package>, so any option using such tags will not be converted at all.
98 lines
2.6 KiB
Nix
98 lines
2.6 KiB
Nix
{ config, pkgs, lib, ... }:
|
|
|
|
with 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"
|
|
"--module-path=${concatStringsSep ":" (["${cfg.package}/lib/syslog-ng"] ++ cfg.extraModulePaths)}"
|
|
"--cfgfile=${syslogngConfig}"
|
|
"--control=${ctrlSocket}"
|
|
"--persist-file=${persistFile}"
|
|
"--pidfile=${pidFile}"
|
|
];
|
|
|
|
in {
|
|
imports = [
|
|
(mkRemovedOptionModule [ "services" "syslog-ng" "serviceName" ] "")
|
|
(mkRemovedOptionModule [ "services" "syslog-ng" "listenToJournal" ] "")
|
|
];
|
|
|
|
options = {
|
|
|
|
services.syslog-ng = {
|
|
enable = mkOption {
|
|
type = types.bool;
|
|
default = false;
|
|
description = lib.mdDoc ''
|
|
Whether to enable the syslog-ng daemon.
|
|
'';
|
|
};
|
|
package = mkOption {
|
|
type = types.package;
|
|
default = pkgs.syslogng;
|
|
defaultText = literalExpression "pkgs.syslogng";
|
|
description = lib.mdDoc ''
|
|
The package providing syslog-ng binaries.
|
|
'';
|
|
};
|
|
extraModulePaths = mkOption {
|
|
type = types.listOf types.str;
|
|
default = [];
|
|
description = lib.mdDoc ''
|
|
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 = lib.mdDoc ''
|
|
Configuration added to the end of `syslog-ng.conf`.
|
|
'';
|
|
};
|
|
configHeader = mkOption {
|
|
type = types.lines;
|
|
default = ''
|
|
@version: 3.6
|
|
@include "scl.conf"
|
|
'';
|
|
description = lib.mdDoc ''
|
|
The very first lines of the configuration file. Should usually contain
|
|
the syslog-ng version header.
|
|
'';
|
|
};
|
|
};
|
|
};
|
|
|
|
config = mkIf cfg.enable {
|
|
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";
|
|
ExecStart = "${cfg.package}/sbin/syslog-ng ${concatStringsSep " " syslogngOptions}";
|
|
ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID";
|
|
};
|
|
};
|
|
};
|
|
|
|
}
|