The StartLimitBurst and StartLimitIntervalSec options belong to the [Unit] section, otherwise they are ignored in [Service]: > Unknown key 'StartLimitIntervalSec' in section [Service], ignoring. When using [Unit], the limits are properly set: apex% systemctl show power-policy.service | grep StartLimit StartLimitIntervalUSec=10min StartLimitBurst=10 StartLimitAction=none Reviewed-by: Aleix Boné <abonerib@bsc.es>
34 lines
772 B
Nix
34 lines
772 B
Nix
{ config, lib, pkgs, ... }:
|
|
|
|
with lib;
|
|
|
|
let
|
|
cfg = config.power.policy;
|
|
in
|
|
{
|
|
options = {
|
|
power.policy = mkOption {
|
|
type = types.nullOr (types.enum [ "always-on" "previous" "always-off" ]);
|
|
default = null;
|
|
description = "Set power policy to use via IPMI.";
|
|
};
|
|
};
|
|
|
|
config = mkIf (cfg != null) {
|
|
systemd.services."power-policy" = {
|
|
description = "Set power policy to use via IPMI";
|
|
wantedBy = [ "multi-user.target" ];
|
|
unitConfig = {
|
|
StartLimitBurst = "10";
|
|
StartLimitIntervalSec = "10m";
|
|
};
|
|
serviceConfig = {
|
|
ExecStart = "${pkgs.ipmitool}/bin/ipmitool chassis policy ${cfg}";
|
|
Type = "oneshot";
|
|
Restart = "on-failure";
|
|
RestartSec = "5s";
|
|
};
|
|
};
|
|
};
|
|
}
|