mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-02-21 11:34:13 +00:00
nixos/ups: add system-ups.slice (#338556)
This commit is contained in:
commit
b12aa4265c
@ -509,6 +509,11 @@ in
|
||||
else lib.unique (lib.forEach cfg.upsd.listen (listen: listen.port));
|
||||
};
|
||||
|
||||
systemd.slices.system-ups = {
|
||||
description = "Network UPS Tools (NUT) Slice";
|
||||
documentation = [ "https://networkupstools.org/" ];
|
||||
};
|
||||
|
||||
systemd.services.upsmon = let
|
||||
secrets = lib.mapAttrsToList (name: monitor: "upsmon_password_${name}") cfg.upsmon.monitor;
|
||||
createUpsmonConf = installSecrets upsmonConf "/run/nut/upsmon.conf" secrets;
|
||||
@ -523,6 +528,7 @@ in
|
||||
ExecStart = "${pkgs.nut}/sbin/upsmon";
|
||||
ExecReload = "${pkgs.nut}/sbin/upsmon -c reload";
|
||||
LoadCredential = lib.mapAttrsToList (name: monitor: "upsmon_password_${name}:${monitor.passwordFile}") cfg.upsmon.monitor;
|
||||
Slice = "system-ups.slice";
|
||||
};
|
||||
environment = envVars;
|
||||
};
|
||||
@ -542,6 +548,7 @@ in
|
||||
ExecStart = "${pkgs.nut}/sbin/upsd -u root";
|
||||
ExecReload = "${pkgs.nut}/sbin/upsd -c reload";
|
||||
LoadCredential = lib.mapAttrsToList (name: user: "upsdusers_password_${name}:${user.passwordFile}") cfg.users;
|
||||
Slice = "system-ups.slice";
|
||||
};
|
||||
environment = envVars;
|
||||
restartTriggers = [
|
||||
@ -559,6 +566,7 @@ in
|
||||
RemainAfterExit = true;
|
||||
# TODO: replace 'root' by another username.
|
||||
ExecStart = "${pkgs.nut}/bin/upsdrvctl -u root start";
|
||||
Slice = "system-ups.slice";
|
||||
};
|
||||
environment = envVars;
|
||||
restartTriggers = [
|
||||
|
Loading…
Reference in New Issue
Block a user