Delay shutdown to August 3rd at 22h and turn on when power is back automatically #152

Manually merged
rarias merged 4 commits from adjust-august-shutdown into master 2025-07-24 11:25:02 +02:00
5 changed files with 47 additions and 3 deletions

View File

@@ -3,6 +3,7 @@
# Includes the basic configuration for an Intel server. # Includes the basic configuration for an Intel server.
imports = [ imports = [
./base/agenix.nix ./base/agenix.nix
./base/always-power-on.nix
./base/august-shutdown.nix ./base/august-shutdown.nix
./base/boot.nix ./base/boot.nix
./base/env.nix ./base/env.nix

View File

@@ -0,0 +1,8 @@
{
imports = [
../../module/power-policy.nix
];
# Turn on as soon as we have power
power.policy = "always-on";
}

View File

@@ -1,12 +1,12 @@
{ {
# Shutdown all machines on August 2nd at 11:00 AM, so we can protect the # Shutdown all machines on August 3rd at 22:00, so we can protect the
# hardware from spurious electrical peaks on the yearly electrical cut for # hardware from spurious electrical peaks on the yearly electrical cut for
# manteinance that starts on August 4th. # manteinance that starts on August 4th.
systemd.timers.august-shutdown = { systemd.timers.august-shutdown = {
description = "Shutdown on August 2nd for maintenance"; description = "Shutdown on August 3rd for maintenance";
wantedBy = [ "timers.target" ]; wantedBy = [ "timers.target" ];
timerConfig = { timerConfig = {
OnCalendar = "*-08-02 11:00:00"; OnCalendar = "*-08-03 22:00:00";
RandomizedDelaySec = "10min"; RandomizedDelaySec = "10min";
Unit = "systemd-poweroff.service"; Unit = "systemd-poweroff.service";
}; };

View File

@@ -8,6 +8,10 @@
../module/nvidia.nix ../module/nvidia.nix
]; ];
# Don't turn off on August as UPC has different dates.
# Fox works fine on power cuts.
systemd.timers.august-shutdown.enable = false;
# Select the this using the ID to avoid mismatches # Select the this using the ID to avoid mismatches
boot.loader.grub.device = "/dev/disk/by-id/wwn-0x500a07514b0c1103"; boot.loader.grub.device = "/dev/disk/by-id/wwn-0x500a07514b0c1103";

31
m/module/power-policy.nix Normal file
View File

@@ -0,0 +1,31 @@
{ 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" ];
serviceConfig = {
ExecStart = "${pkgs.ipmitool}/bin/ipmitool chassis policy ${cfg}";
Type = "oneshot";
Restart = "on-failure";
RestartSec = "5s";
StartLimitBurst = "10";
StartLimitIntervalSec = "10m";
};
};
};
}