nixos-config/system/power.nix

44 lines
1.1 KiB
Nix

{lib, config, ...}: {
imports = [
../options.nix
];
services = {
thermald.enable = config.useThermald;
tlp = lib.mkIf (config.has_battery) {
enable = true;
settings = {
WIFI_PWR_ON_BAT = "on";
DEVICES_TO_ENABLE_ON_STARTUP = "wifi bluetooth";
DEVICES_TO_DISABLE_ON_STARTUP = "";
DEVICES_TO_DISABLE_ON_AC = "";
DEVICES_TO_DISABLE_ON_BAT = "";
START_CHARGE_THRESH_BAT0 = 50;
STOP_CHARGE_THRESH_BAT0 = 85;
};
} // config.tlpConfig or {};
auto-cpufreq = lib.mkIf (config.has_battery) {
enable = true;
settings = {
battery = {
governor = "powersave"; # Set the CPU governor to powersave.
energy_performance_preference = "power";
turbo = "never";
# enable_thresholds = true;
# start_threshold = 50;
# stop_threshold = 90;
};
charger = {
governor = "performance"; # Set the CPU governor to performance when charging.
turbo = "auto";
};
};
} // config.cpufreqConfig or {};
};
}