about summary refs log tree commit diff
path: root/nixos/modules/services
diff options
context:
space:
mode:
authorRyan Lahfa <masterancpp@gmail.com>2022-12-30 14:13:53 +0100
committerGitHub <noreply@github.com>2022-12-30 14:13:53 +0100
commit30307eba489f410f8f7aad23d62a3d797e9dd5d7 (patch)
tree1c87d4b2b137d7a04268a0e36d6dafd4b3913494 /nixos/modules/services
parentbb0949f4e294941e5d638ad87d6af1ee77186142 (diff)
parentbcbedfeefc21fee3e3f7f897c803adfad425f6d0 (diff)
Merge pull request #207453 from p-h/ulogd
ulogd: init at 2.0.8
Diffstat (limited to 'nixos/modules/services')
-rw-r--r--nixos/modules/services/logging/ulogd.nix48
1 files changed, 48 insertions, 0 deletions
diff --git a/nixos/modules/services/logging/ulogd.nix b/nixos/modules/services/logging/ulogd.nix
new file mode 100644
index 0000000000000..065032b531c6d
--- /dev/null
+++ b/nixos/modules/services/logging/ulogd.nix
@@ -0,0 +1,48 @@
+{ config, lib, pkgs, ... }:
+
+with lib;
+let
+  cfg = config.services.ulogd;
+  settingsFormat = pkgs.formats.ini { };
+  settingsFile = settingsFormat.generate "ulogd.conf" cfg.settings;
+in {
+  options = {
+    services.ulogd = {
+      enable = mkEnableOption (lib.mdDoc "ulogd");
+
+      settings = mkOption {
+        example = {
+          global.stack = "stack=log1:NFLOG,base1:BASE,pcap1:PCAP";
+          log1.group = 2;
+          pcap1 = {
+            file = "/var/log/ulogd.pcap";
+            sync = 1;
+          };
+        };
+        type = settingsFormat.type;
+        default = { };
+        description = lib.mdDoc "Configuration for ulogd. See {file}`/share/doc/ulogd/` in `pkgs.ulogd.doc`.";
+      };
+
+      logLevel = mkOption {
+        type = types.enum [ 1 3 5 7 8 ];
+        default = 5;
+        description = lib.mdDoc "Log level (1 = debug, 3 = info, 5 = notice, 7 = error, 8 = fatal)";
+      };
+    };
+  };
+
+  config = mkIf cfg.enable {
+    systemd.services.ulogd = {
+      description = "Ulogd Daemon";
+      wantedBy = [ "multi-user.target" ];
+      wants = [ "network-pre.target" ];
+      before = [ "network-pre.target" ];
+
+      serviceConfig = {
+        ExecStart = "${pkgs.ulogd}/bin/ulogd -c ${settingsFile} --verbose --loglevel ${toString cfg.logLevel}";
+        ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID";
+      };
+    };
+  };
+}