at 25.11-pre 1.7 kB view raw
1{ 2 config, 3 lib, 4 pkgs, 5 ... 6}: 7let 8 cfg = config.services.ulogd; 9 settingsFormat = pkgs.formats.ini { listsAsDuplicateKeys = true; }; 10 settingsFile = settingsFormat.generate "ulogd.conf" cfg.settings; 11in 12{ 13 options = { 14 services.ulogd = { 15 enable = lib.mkEnableOption "ulogd, a userspace logging daemon for netfilter/iptables related logging"; 16 17 settings = lib.mkOption { 18 example = { 19 global.stack = [ 20 "log1:NFLOG,base1:BASE,ifi1:IFINDEX,ip2str1:IP2STR,print1:PRINTPKT,emu1:LOGEMU" 21 "log1:NFLOG,base1:BASE,pcap1:PCAP" 22 ]; 23 24 log1.group = 2; 25 26 pcap1 = { 27 sync = 1; 28 file = "/var/log/ulogd.pcap"; 29 }; 30 31 emu1 = { 32 sync = 1; 33 file = "/var/log/ulogd_pkts.log"; 34 }; 35 }; 36 type = settingsFormat.type; 37 default = { }; 38 description = "Configuration for ulogd. See {file}`/share/doc/ulogd/` in `pkgs.ulogd.doc`."; 39 }; 40 41 logLevel = lib.mkOption { 42 type = lib.types.enum [ 43 1 44 3 45 5 46 7 47 8 48 ]; 49 default = 5; 50 description = "Log level (1 = debug, 3 = info, 5 = notice, 7 = error, 8 = fatal)"; 51 }; 52 }; 53 }; 54 55 config = lib.mkIf cfg.enable { 56 systemd.services.ulogd = { 57 description = "Ulogd Daemon"; 58 wantedBy = [ "multi-user.target" ]; 59 wants = [ "network-pre.target" ]; 60 before = [ "network-pre.target" ]; 61 62 serviceConfig = { 63 ExecStart = "${pkgs.ulogd}/bin/ulogd -c ${settingsFile} --verbose --loglevel ${toString cfg.logLevel}"; 64 ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID"; 65 }; 66 }; 67 }; 68}