Skip to content

Commit b12aa42

Browse files
authored
nixos/ups: add system-ups.slice (#338556)
2 parents 2976874 + 2ae2834 commit b12aa42

File tree

1 file changed

+8
-0
lines changed
  • nixos/modules/services/monitoring

1 file changed

+8
-0
lines changed

nixos/modules/services/monitoring/ups.nix

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,11 @@ in
509509
else lib.unique (lib.forEach cfg.upsd.listen (listen: listen.port));
510510
};
511511

512+
systemd.slices.system-ups = {
513+
description = "Network UPS Tools (NUT) Slice";
514+
documentation = [ "https://networkupstools.org/" ];
515+
};
516+
512517
systemd.services.upsmon = let
513518
secrets = lib.mapAttrsToList (name: monitor: "upsmon_password_${name}") cfg.upsmon.monitor;
514519
createUpsmonConf = installSecrets upsmonConf "/run/nut/upsmon.conf" secrets;
@@ -523,6 +528,7 @@ in
523528
ExecStart = "${pkgs.nut}/sbin/upsmon";
524529
ExecReload = "${pkgs.nut}/sbin/upsmon -c reload";
525530
LoadCredential = lib.mapAttrsToList (name: monitor: "upsmon_password_${name}:${monitor.passwordFile}") cfg.upsmon.monitor;
531+
Slice = "system-ups.slice";
526532
};
527533
environment = envVars;
528534
};
@@ -542,6 +548,7 @@ in
542548
ExecStart = "${pkgs.nut}/sbin/upsd -u root";
543549
ExecReload = "${pkgs.nut}/sbin/upsd -c reload";
544550
LoadCredential = lib.mapAttrsToList (name: user: "upsdusers_password_${name}:${user.passwordFile}") cfg.users;
551+
Slice = "system-ups.slice";
545552
};
546553
environment = envVars;
547554
restartTriggers = [
@@ -559,6 +566,7 @@ in
559566
RemainAfterExit = true;
560567
# TODO: replace 'root' by another username.
561568
ExecStart = "${pkgs.nut}/bin/upsdrvctl -u root start";
569+
Slice = "system-ups.slice";
562570
};
563571
environment = envVars;
564572
restartTriggers = [

0 commit comments

Comments
 (0)