mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-11 20:25:32 +03:00
cpu-freq: Use cpupower instead of cpufrequtils
Additionally, put the powersave utility in charge of loading the cpufrequency modules based on the governor specified in the configuration.
This commit is contained in:
parent
171a58bcd6
commit
dd209e901c
2 changed files with 23 additions and 26 deletions
|
@ -2,6 +2,11 @@
|
|||
|
||||
with lib;
|
||||
|
||||
let
|
||||
cpupower = config.boot.kernelPackages.cpupower;
|
||||
cfg = config.powerManagement;
|
||||
in
|
||||
|
||||
{
|
||||
###### interface
|
||||
|
||||
|
@ -25,29 +30,25 @@ with lib;
|
|||
|
||||
config = mkIf (config.powerManagement.cpuFreqGovernor != null) {
|
||||
|
||||
environment.systemPackages = [ pkgs.cpufrequtils ];
|
||||
boot.kernelModules = [ "acpi-cpufreq" "speedstep-lib" "pcc-cpufreq"
|
||||
"cpufreq_${cfg.cpuFreqGovernor}"
|
||||
];
|
||||
|
||||
jobs.cpufreq =
|
||||
{ description = "CPU Frequency Governor Setup";
|
||||
environment.systemPackages = [ cpupower ];
|
||||
|
||||
after = [ "systemd-modules-load.service" ];
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
|
||||
unitConfig.ConditionPathIsReadWrite = "/sys/devices/";
|
||||
|
||||
path = [ pkgs.cpufrequtils ];
|
||||
|
||||
preStart = ''
|
||||
for i in $(seq 0 $(($(nproc) - 1))); do
|
||||
for gov in $(cpufreq-info -c $i -g); do
|
||||
if [ "$gov" = ${config.powerManagement.cpuFreqGovernor} ]; then
|
||||
echo "<6>setting governor on CPU $i to ‘$gov’"
|
||||
cpufreq-set -c $i -g $gov
|
||||
fi
|
||||
done
|
||||
done
|
||||
'';
|
||||
systemd.services.cpufreq = {
|
||||
description = "CPU Frequency Governor Setup";
|
||||
after = [ "systemd-modules-load.service" ];
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
path = [ cpupower ];
|
||||
script = ''
|
||||
cpupower frequency-set -g ${cfg.cpuFreqGovernor}
|
||||
'';
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
RemainAfterExit = "yes";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue