1{ config, lib, pkgs, ... }:
2
3with lib;
4let
5 cfg = config.services.ulogd;
6 settingsFormat = pkgs.formats.ini { };
7 settingsFile = settingsFormat.generate "ulogd.conf" cfg.settings;
8in {
9 options = {
10 services.ulogd = {
11 enable = mkEnableOption (lib.mdDoc "ulogd");
12
13 settings = mkOption {
14 example = {
15 global.stack = "stack=log1:NFLOG,base1:BASE,pcap1:PCAP";
16 log1.group = 2;
17 pcap1 = {
18 file = "/var/log/ulogd.pcap";
19 sync = 1;
20 };
21 };
22 type = settingsFormat.type;
23 default = { };
24 description = lib.mdDoc "Configuration for ulogd. See {file}`/share/doc/ulogd/` in `pkgs.ulogd.doc`.";
25 };
26
27 logLevel = mkOption {
28 type = types.enum [ 1 3 5 7 8 ];
29 default = 5;
30 description = lib.mdDoc "Log level (1 = debug, 3 = info, 5 = notice, 7 = error, 8 = fatal)";
31 };
32 };
33 };
34
35 config = mkIf cfg.enable {
36 systemd.services.ulogd = {
37 description = "Ulogd Daemon";
38 wantedBy = [ "multi-user.target" ];
39 wants = [ "network-pre.target" ];
40 before = [ "network-pre.target" ];
41
42 serviceConfig = {
43 ExecStart = "${pkgs.ulogd}/bin/ulogd -c ${settingsFile} --verbose --loglevel ${toString cfg.logLevel}";
44 ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID";
45 };
46 };
47 };
48}