From ac700d34a5fb9803313a631ee9c1cef932b39b8c Mon Sep 17 00:00:00 2001 From: Rodrigo Arias Mallo Date: Wed, 23 Jul 2025 13:40:33 +0200 Subject: [PATCH 1/4] Disable automatic August shutdown for Fox MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The UPC has different dates for the yearly power cut, and Fox can recover properly from a power loss, so we don't need to have it turned off before the power cut. Simply disabling the timer is enough. Reviewed-by: Aleix Roca Nonell Reviewed-by: Aleix Boné --- m/fox/configuration.nix | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/m/fox/configuration.nix b/m/fox/configuration.nix index fd5cdc8b..436a85ec 100644 --- a/m/fox/configuration.nix +++ b/m/fox/configuration.nix @@ -8,6 +8,10 @@ ../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 boot.loader.grub.device = "/dev/disk/by-id/wwn-0x500a07514b0c1103"; -- 2.51.2 From 9a056737de61c4ba8eac0585a03745517cb8fecd Mon Sep 17 00:00:00 2001 From: Rodrigo Arias Mallo Date: Wed, 23 Jul 2025 13:42:57 +0200 Subject: [PATCH 2/4] Move August shutdown to 3rd at 22h MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: Aleix Roca Nonell Reviewed-by: Aleix Boné --- m/common/base/august-shutdown.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/m/common/base/august-shutdown.nix b/m/common/base/august-shutdown.nix index 624340c4..7f79c849 100644 --- a/m/common/base/august-shutdown.nix +++ b/m/common/base/august-shutdown.nix @@ -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 # manteinance that starts on August 4th. systemd.timers.august-shutdown = { - description = "Shutdown on August 2nd for maintenance"; + description = "Shutdown on August 3rd for maintenance"; wantedBy = [ "timers.target" ]; timerConfig = { - OnCalendar = "*-08-02 11:00:00"; + OnCalendar = "*-08-03 22:00:00"; RandomizedDelaySec = "10min"; Unit = "systemd-poweroff.service"; }; -- 2.51.2 From 30b9b23112f76a213a1ecff69d9d51a24770329b Mon Sep 17 00:00:00 2001 From: Rodrigo Arias Mallo Date: Wed, 23 Jul 2025 14:07:06 +0200 Subject: [PATCH 3/4] Add NixOS module to control power policy MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: Aleix Roca Nonell Reviewed-by: Aleix Boné --- m/module/power-policy.nix | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 m/module/power-policy.nix diff --git a/m/module/power-policy.nix b/m/module/power-policy.nix new file mode 100644 index 00000000..87c04140 --- /dev/null +++ b/m/module/power-policy.nix @@ -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"; + }; + }; + }; +} -- 2.51.2 From 8f7787e217ce4f984d0d67b31a827b03e6f73185 Mon Sep 17 00:00:00 2001 From: Rodrigo Arias Mallo Date: Wed, 23 Jul 2025 15:25:47 +0200 Subject: [PATCH 4/4] Set power policy to always turn on MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In all machines, as soon as we recover the power, turn the machine back on. We cannot rely on the previous state as we will shut them down before the power is cut to prevent damage on the power supply monitoring circuit. Reviewed-by: Aleix Roca Nonell Reviewed-by: Aleix Boné --- m/common/base.nix | 1 + m/common/base/always-power-on.nix | 8 ++++++++ 2 files changed, 9 insertions(+) create mode 100644 m/common/base/always-power-on.nix diff --git a/m/common/base.nix b/m/common/base.nix index bb0e4e22..cdd1dc19 100644 --- a/m/common/base.nix +++ b/m/common/base.nix @@ -3,6 +3,7 @@ # Includes the basic configuration for an Intel server. imports = [ ./base/agenix.nix + ./base/always-power-on.nix ./base/august-shutdown.nix ./base/boot.nix ./base/env.nix diff --git a/m/common/base/always-power-on.nix b/m/common/base/always-power-on.nix new file mode 100644 index 00000000..cdee12c6 --- /dev/null +++ b/m/common/base/always-power-on.nix @@ -0,0 +1,8 @@ +{ + imports = [ + ../../module/power-policy.nix + ]; + + # Turn on as soon as we have power + power.policy = "always-on"; +} -- 2.51.2