Skip to content

Commit dd0d2d0

Browse files
committed
simplify systemd service config
1 parent ed24a24 commit dd0d2d0

File tree

1 file changed

+10
-28
lines changed

1 file changed

+10
-28
lines changed

nix/nixos-module.nix

Lines changed: 10 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -42,38 +42,20 @@ in {
4242
after = ["network-online.target"];
4343
serviceConfig = {
4444
ExecStart = "${cfg.package}/bin/defguard-service --log-level ${cfg.logLevel} --stats-period ${toString cfg.statsPeriod}";
45-
Restart = "on-failure";
46-
RestartSec = 5;
47-
User = "defguard";
45+
ExecReload = "/bin/kill -HUP $MAINPID";
4846
Group = "defguard";
49-
StateDirectory = "defguard-service";
50-
LogsDirectory = "defguard-service";
51-
# Add capabilities to manage network interfaces
52-
CapabilityBoundingSet = "CAP_NET_ADMIN CAP_NET_RAW CAP_SYS_MODULE";
53-
AmbientCapabilities = "CAP_NET_ADMIN CAP_NET_RAW CAP_SYS_MODULE";
54-
# Allow access to /dev/net/tun for TUN/TAP devices
55-
DeviceAllow = "/dev/net/tun rw";
56-
# Access to /sys for network configuration
57-
BindReadOnlyPaths = [
58-
"/sys"
59-
"/proc"
60-
];
61-
# Protect the system while giving necessary access
62-
ProtectSystem = "strict";
63-
ProtectHome = true;
64-
NoNewPrivileges = true;
65-
# Allow the service to manage network namespaces
66-
PrivateNetwork = false;
47+
Restart = "on-failure";
48+
RestartSec = 2;
49+
KillMode = "process";
50+
KillSignal = "SIGINT";
51+
LimitNOFILE = 65536;
52+
LimitNPROC = "infinity";
53+
TasksMax = "infinity";
54+
OOMScoreAdjust = -1000;
6755
};
6856
};
6957

70-
# Setup defguard user & group
71-
users.users.defguard = {
72-
isSystemUser = true;
73-
group = "defguard";
74-
};
75-
76-
# Make sure the group exists
58+
# Make sure the defguard group exists
7759
users.groups.defguard = {};
7860
};
7961
}

0 commit comments

Comments
 (0)