powersave config

This commit is contained in:
Sergei Poljanski 2026-03-20 20:18:05 +03:00
commit 45ab7efecf
Signed by: asxpi
GPG key ID: 4F8851660FA4121B
3 changed files with 64 additions and 0 deletions

View file

@ -15,6 +15,7 @@
./modules/programs.nix ./modules/programs.nix
./modules/wireguard.nix ./modules/wireguard.nix
./modules/security.nix ./modules/security.nix
./modules/power.nix
]; ];
# This value determines the NixOS release from which the default # This value determines the NixOS release from which the default

View file

@ -95,6 +95,8 @@
kubectx # switch between contexts/namespaces kubectx # switch between contexts/namespaces
stern # multi-pod log tailing stern # multi-pod log tailing
hcloud # Hetzner Cloud CLI hcloud # Hetzner Cloud CLI
packer # image builder
talosctl # Talos OS CLI
eksctl # AWS EKS CLI eksctl # AWS EKS CLI
# terragrunt # broken in nixpkgs # terragrunt # broken in nixpkgs
gh gh

61
modules/power.nix Normal file
View file

@ -0,0 +1,61 @@
# Power management — ThinkPad T14 Gen 2 (AMD)
{ config, pkgs, lib, ... }:
{
# AMD P-State driver (active mode for full EPP control)
boot.kernelParams = [ "amd_pstate=active" ];
# CPU frequency scaling
powerManagement.cpuFreqGovernor = "powersave";
# Disable power-profiles-daemon (conflicts with TLP)
services.power-profiles-daemon.enable = false;
# TLP — main power management daemon
services.tlp = {
enable = true;
settings = {
# CPU
CPU_SCALING_GOVERNOR_ON_AC = "performance";
CPU_SCALING_GOVERNOR_ON_BAT = "powersave";
CPU_ENERGY_PERF_POLICY_ON_AC = "balance_performance";
CPU_ENERGY_PERF_POLICY_ON_BAT = "power";
CPU_BOOST_ON_AC = 1;
CPU_BOOST_ON_BAT = 0;
PLATFORM_PROFILE_ON_AC = "balanced";
PLATFORM_PROFILE_ON_BAT = "low-power";
# AMD P-State
CPU_DRIVER_OPMODE_ON_AC = "active";
CPU_DRIVER_OPMODE_ON_BAT = "active";
# WiFi
WIFI_PWR_MGT_ON_AC = "off";
WIFI_PWR_MGT_ON_BAT = "on";
# PCIe ASPM
PCIE_ASPM_ON_AC = "default";
PCIE_ASPM_ON_BAT = "powersupersave";
# Runtime PM
RUNTIME_PM_ON_AC = "on";
RUNTIME_PM_ON_BAT = "auto";
# NVMe
NVME_RUNTIME_PM_ON_AC = "on";
NVME_RUNTIME_PM_ON_BAT = "auto";
# USB autosuspend
USB_AUTOSUSPEND = 1;
};
};
# Bluetooth off at boot
hardware.bluetooth.powerOnBoot = false;
# Battery monitoring
services.upower.enable = true;
# powertop for diagnostics
environment.systemPackages = [ pkgs.powertop ];
}