2024-09-09 00:22:14 +00:00
|
|
|
{
|
2024-09-13 01:50:53 +00:00
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
...
|
|
|
|
}:
|
|
|
|
with lib; let
|
|
|
|
cfg = config.custom.services.auto-cpufreq;
|
|
|
|
in {
|
2024-09-09 00:22:14 +00:00
|
|
|
options.custom.services.auto-cpufreq = {
|
2024-09-13 01:50:53 +00:00
|
|
|
enable = mkOption {default = false;};
|
2024-09-09 00:22:14 +00:00
|
|
|
|
|
|
|
max = {
|
2024-09-13 01:50:53 +00:00
|
|
|
battery = mkOption {default = null;}; # GHz
|
|
|
|
charger = mkOption {default = null;}; # GHz
|
2024-09-09 00:22:14 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
# https://github.com/AdnanHodzic/auto-cpufreq
|
|
|
|
#?? auto-cpufreq --stats
|
|
|
|
#?? cpu-power freqency-info
|
|
|
|
#?? grep '' /sys/devices/system/cpu/cpu0/cpufreq/*
|
|
|
|
services = {
|
|
|
|
auto-cpufreq = {
|
|
|
|
enable = true;
|
|
|
|
|
|
|
|
# https://github.com/AdnanHodzic/auto-cpufreq/blob/master/auto-cpufreq.conf-example
|
|
|
|
settings = {
|
|
|
|
battery = {
|
2024-12-21 18:30:03 +00:00
|
|
|
energy_performance_preference = "power";
|
2024-09-09 00:22:14 +00:00
|
|
|
governor = "powersave";
|
2024-10-24 16:24:54 +00:00
|
|
|
platform_profile = "low-power";
|
2024-10-30 14:43:41 +00:00
|
|
|
scaling_max_freq = mkIf (isFloat cfg.max.battery || isInt cfg.max.battery) (builtins.floor (cfg.max.battery * 1000 * 1000)); # KHz
|
2024-09-09 00:22:14 +00:00
|
|
|
#// turbo = "never"; # Only works with acpi-cpufreq
|
|
|
|
};
|
|
|
|
|
|
|
|
charger = {
|
|
|
|
energy_performance_preference = "balance_performance";
|
|
|
|
governor = "powersave";
|
2024-10-24 16:24:54 +00:00
|
|
|
platform_profile = "balanced";
|
2024-10-30 14:43:41 +00:00
|
|
|
scaling_max_freq = mkIf (isFloat cfg.max.charger || isInt cfg.max.charger) (builtins.floor (cfg.max.charger * 1000 * 1000)); # KHz
|
2024-09-09 00:22:14 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2024-10-24 16:24:54 +00:00
|
|
|
#!! Conflicts with auto-cpufreq
|
|
|
|
power-profiles-daemon.enable = false;
|
|
|
|
tlp.enable = false;
|
2024-09-09 00:22:14 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|