1 { config, lib, pkgs, ... }:
6 cfg = config.services.vnstat;
8 options.services.vnstat = {
9 enable = mkEnableOption "update of network usage statistics via vnstatd";
12 config = mkIf cfg.enable {
14 environment.systemPackages = [ pkgs.vnstat ];
22 description = "vnstat daemon user";
26 systemd.services.vnstat = {
27 description = "vnStat network traffic monitor";
28 path = [ pkgs.coreutils ];
29 after = [ "network.target" ];
30 wantedBy = [ "multi-user.target" ];
37 ExecStart = "${pkgs.vnstat}/bin/vnstatd -n";
38 ExecReload = "${pkgs.procps}/bin/kill -HUP $MAINPID";
40 # Hardening (from upstream example service)
41 ProtectSystem = "strict";
42 StateDirectory = "vnstat";
43 PrivateDevices = true;
44 ProtectKernelTunables = true;
45 ProtectControlGroups = true;
47 ProtectKernelModules = true;
49 MemoryDenyWriteExecute = true;
50 RestrictRealtime = true;
51 RestrictNamespaces = true;
59 meta.maintainers = [ maintainers.evils ];