panacea/modules/power.nix

39 lines
1.0 KiB
Nix

{ config, lib, pkgs, ... }:
{
# Enable the TLP daemon
services.tlp = {
enable = true;
settings = {
CPU_MIN_PERF_ON_AC = 0;
CPU_MAX_PERF_ON_AC = 100;
CPU_MIN_PERF_ON_BAT = 0;
CPU_MAX_PERF_ON_BAT = 50;
};
};
# Suspend when the battery is critical and autosuspend USB and PCI
services.udev.extraRules = ''
SUBSYSTEM=="power_supply", ATTR{status}=="Discharging", ATTR{model_name}=="01AV405", ATTR{capacity}=="[0-5]", RUN+="${config.systemd.package}/bin/systemctl suspend -i"
ACTION=="add", SUBSYSTEM=="usb", TEST=="power/control", ATTR{power/control}="auto"
ACTION=="add", SUBSYSTEM=="pci", TEST=="power/control", ATTR{power/control}="auto"
'';
# Undervolt CPU and GPU
services.undervolt = {
enable = true;
coreOffset = -100;
gpuOffset = -75;
};
# Prevent overheating of the CPU
services.thermald.enable = true;
# Provide power management support to programs
services.upower.enable = true;
# Turn off keyboard backlight when unused
services.tp-auto-kbbl.enable = true;
}