{ inputs, povSelf, config, lib, pkgs, ... }: let inherit (lib) types; cfg = lib.getAttrFromPath povSelf config; in { options = { enable = { type = types.bool; default = false; }; vnstati.enable = { type = types.bool; default = false; }; }; config = lib.mkIf cfg.enable { services.vnstat.enable = true; modules.filesystem.impermanence.system.dirs = [ "/var/lib/vnstat" ]; services.nginx.virtualHosts."${config.networking.fqdn}" = lib.mkIf cfg.vnstati.enable { locations."/vnstat/" = { alias = "/var/run/vnstati/"; index = "index.html"; }; }; systemd.services.vnstati = lib.mkIf cfg.vnstati.enable { wantedBy = [ "multi-user.target" ]; after = [ "vnstat.service" ]; startAt = "*-*-* *:0/10:00"; serviceConfig = { User = "vnstatd"; Group = "vnstatd"; RuntimeDirectoryPreserve = true; RuntimeDirectory = "vnstati"; RuntimeDirectoryMode = 775; PrivateTmp = true; ProtectHome = true; ProtectSystem = "strict"; }; path = with pkgs; [ vnstat jq nix ]; script = '' set -x ifaces=$(vnstat --json | jq -r .interfaces[].name | grep -v "^lo$") echo $ifaces cat > /var/run/vnstati/index.html << EOF