1 { config, pkgs, lib, ... }:
5 let cfg = config.services.nzbhydra2;
10 enable = mkEnableOption (lib.mdDoc "NZBHydra2");
14 default = "/var/lib/nzbhydra2";
15 description = lib.mdDoc "The directory where NZBHydra2 stores its data files.";
18 openFirewall = mkOption {
22 lib.mdDoc "Open ports in the firewall for the NZBHydra2 web interface.";
27 default = pkgs.nzbhydra2;
28 defaultText = literalExpression "pkgs.nzbhydra2";
29 description = lib.mdDoc "NZBHydra2 package to use.";
34 config = mkIf cfg.enable {
35 systemd.tmpfiles.rules =
36 [ "d '${cfg.dataDir}' 0700 nzbhydra2 nzbhydra2 - -" ];
38 systemd.services.nzbhydra2 = {
39 description = "NZBHydra2";
40 after = [ "network.target" ];
41 wantedBy = [ "multi-user.target" ];
48 "${cfg.package}/bin/nzbhydra2 --nobrowser --datafolder '${cfg.dataDir}'";
49 Restart = "on-failure";
51 NoNewPrivileges = true;
53 PrivateDevices = true;
54 DevicePolicy = "closed";
55 ProtectSystem = "strict";
56 ReadWritePaths = cfg.dataDir;
57 ProtectHome = "read-only";
58 ProtectControlGroups = true;
59 ProtectKernelModules = true;
60 ProtectKernelTunables = true;
61 RestrictAddressFamilies ="AF_UNIX AF_INET AF_INET6 AF_NETLINK";
62 RestrictNamespaces = true;
63 RestrictRealtime = true;
64 RestrictSUIDSGID = true;
65 LockPersonality = true;
69 networking.firewall = mkIf cfg.openFirewall { allowedTCPPorts = [ 5076 ]; };
71 users.users.nzbhydra2 = {
76 users.groups.nzbhydra2 = {};