From f32139af2cd80b0f4fe7f82d3ff52100f5a2300f Mon Sep 17 00:00:00 2001 From: TheGeneralist <180094941+thegeneralist01@users.noreply.github.com> Date: Fri, 9 Oct 2026 14:50:35 +0200 Subject: [PATCH] nixos: reduce idle power usage --- .../thegeneralist/hardware-configuration.nix | 30 ++++++++++++++++++- modules/linux/xserver.nix | 12 ++++++++ 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/hosts/thegeneralist/hardware-configuration.nix b/hosts/thegeneralist/hardware-configuration.nix index 5ce6e12..f03d750 100644 --- a/hosts/thegeneralist/hardware-configuration.nix +++ b/hosts/thegeneralist/hardware-configuration.nix @@ -1,4 +1,4 @@ -{ config, lib, modulesPath, ... }: +{ config, lib, modulesPath, pkgs, ... }: { imports = @@ -23,6 +23,33 @@ boot.kernelParams = [ "usbcore.autosuspend=-1" ]; networking.networkmanager.wifi.powersave = false; + # Favor efficient idle and light-load operation without suspending this + # always-on host. The EPP setting retains short performance bursts. + powerManagement = { + cpuFreqGovernor = "powersave"; + scsiLinkPolicy = "med_power_with_dipm"; + }; + systemd.services.energy-policy = { + description = "Apply host energy policy"; + wantedBy = [ "multi-user.target" ]; + after = [ "systemd-modules-load.service" "local-fs.target" ]; + serviceConfig.Type = "oneshot"; + script = '' + for policy in /sys/devices/system/cpu/cpufreq/policy*; do + if [ -w "$policy/energy_performance_preference" ]; then + echo balance_power > "$policy/energy_performance_preference" + fi + done + + # This unmounted archival HDD wakes transparently when accessed. + disk=/dev/disk/by-id/ata-ST1000DM010-2EP102_ZN1043CH + if [ -b "$disk" ]; then + ${pkgs.hdparm}/bin/hdparm -S 120 "$disk" + fi + ''; + }; + boot.kernel.sysctl."kernel.nmi_watchdog" = 0; + fileSystems."/" = { device = "/dev/disk/by-label/NIXROOT"; @@ -42,6 +69,7 @@ options = [ "nofail" "x-systemd.automount" + "noatime" ]; }; diff --git a/modules/linux/xserver.nix b/modules/linux/xserver.nix index 25ffe69..d57fc32 100644 --- a/modules/linux/xserver.nix +++ b/modules/linux/xserver.nix @@ -66,6 +66,18 @@ }; }; + # Blank displays without suspending the machine or its services. + services.swayidle = { + enable = true; + timeouts = [{ + timeout = 600; + command = "${pkgs.niri}/bin/niri msg action power-off-monitors"; + resumeCommand = "${pkgs.niri}/bin/niri msg action power-on-monitors"; + }]; + events.before-sleep = + "${pkgs.niri}/bin/niri msg action power-off-monitors"; + }; + programs.niri = { enable = true; package = pkgs.niri;