diff --git a/nixos/modules/services/monitoring/ups.nix b/nixos/modules/services/monitoring/ups.nix index 3c102be691c33..adc403e663606 100644 --- a/nixos/modules/services/monitoring/ups.nix +++ b/nixos/modules/services/monitoring/ups.nix @@ -8,6 +8,11 @@ let cfg = config.power.ups; defaultPort = 3493; + envVars = { + NUT_CONFPATH = "/etc/nut"; + NUT_STATEPATH = "/var/lib/nut"; + }; + nutFormat = { type = with lib.types; let @@ -496,7 +501,9 @@ in }) ]; + # For interactive use. environment.systemPackages = [ pkgs.nut ]; + environment.variables = envVars; networking.firewall = mkIf cfg.openFirewall { allowedTCPPorts = @@ -520,8 +527,7 @@ in ExecReload = "${pkgs.nut}/sbin/upsmon -c reload"; LoadCredential = mapAttrsToList (name: monitor: "upsmon_password_${name}:${monitor.passwordFile}") cfg.upsmon.monitor; }; - environment.NUT_CONFPATH = "/etc/nut"; - environment.NUT_STATEPATH = "/var/lib/nut"; + environment = envVars; }; systemd.services.upsd = let @@ -540,8 +546,7 @@ in ExecReload = "${pkgs.nut}/sbin/upsd -c reload"; LoadCredential = mapAttrsToList (name: user: "upsdusers_password_${name}:${user.passwordFile}") cfg.users; }; - environment.NUT_CONFPATH = "/etc/nut"; - environment.NUT_STATEPATH = "/var/lib/nut"; + environment = envVars; restartTriggers = [ config.environment.etc."nut/upsd.conf".source ]; @@ -558,8 +563,7 @@ in # TODO: replace 'root' by another username. ExecStart = "${pkgs.nut}/bin/upsdrvctl -u root start"; }; - environment.NUT_CONFPATH = "/etc/nut"; - environment.NUT_STATEPATH = "/var/lib/nut"; + environment = envVars; restartTriggers = [ config.environment.etc."nut/ups.conf".source ];