panacea/modules/power.nix

39 lines
1.0 KiB
Nix
Raw Normal View History

{ config, lib, pkgs, ... }:
{
2022-04-16 00:08:57 +02:00
# Enable the TLP daemon
2022-10-18 14:55:03 +02:00
services.tlp = {
enable = true;
settings = {
2023-01-13 21:21:36 +01:00
CPU_MIN_PERF_ON_AC = 0;
CPU_MAX_PERF_ON_AC = 100;
CPU_MIN_PERF_ON_BAT = 0;
CPU_MAX_PERF_ON_BAT = 50;
2022-10-18 14:55:03 +02:00
};
};
2022-04-16 00:08:57 +02:00
2023-01-19 12:52:49 +01:00
# Suspend when the battery is critical and autosuspend USB and PCI
2021-02-17 03:50:33 +01:00
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"
2023-01-19 12:52:49 +01:00
ACTION=="add", SUBSYSTEM=="usb", TEST=="power/control", ATTR{power/control}="auto"
ACTION=="add", SUBSYSTEM=="pci", TEST=="power/control", ATTR{power/control}="auto"
2021-02-17 03:50:33 +01:00
'';
2022-06-23 23:31:16 +02:00
2022-12-01 04:37:58 +01:00
# Undervolt CPU and GPU
services.undervolt = {
enable = true;
2022-12-03 14:08:49 +01:00
coreOffset = -100;
gpuOffset = -75;
2022-12-01 04:37:58 +01:00
};
# Prevent overheating of the CPU
services.thermald.enable = true;
2023-01-19 12:52:49 +01:00
# Provide power management support to programs
services.upower.enable = true;
# Turn off keyboard backlight when unused
services.tp-auto-kbbl.enable = true;
}