diff options
author | William A. Kennington III <william@wkennington.com> | 2014-03-17 18:07:46 -0500 |
---|---|---|
committer | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2014-04-16 01:10:26 +0200 |
commit | dd209e901cfbac8e68949b4871d6aece935b6215 (patch) | |
tree | da35e56e96f5e7cdf76de6c587ae384991a86cd4 /nixos/modules/tasks/cpu-freq.nix | |
parent | 171a58bcd68e59d8df461cce133cacb67b488bb2 (diff) | |
download | nixpkgs-dd209e901cfbac8e68949b4871d6aece935b6215.tar nixpkgs-dd209e901cfbac8e68949b4871d6aece935b6215.tar.gz nixpkgs-dd209e901cfbac8e68949b4871d6aece935b6215.tar.bz2 nixpkgs-dd209e901cfbac8e68949b4871d6aece935b6215.tar.lz nixpkgs-dd209e901cfbac8e68949b4871d6aece935b6215.tar.xz nixpkgs-dd209e901cfbac8e68949b4871d6aece935b6215.tar.zst nixpkgs-dd209e901cfbac8e68949b4871d6aece935b6215.zip |
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.
Diffstat (limited to 'nixos/modules/tasks/cpu-freq.nix')
-rw-r--r-- | nixos/modules/tasks/cpu-freq.nix | 43 |
1 files changed, 22 insertions, 21 deletions
diff --git a/nixos/modules/tasks/cpu-freq.nix b/nixos/modules/tasks/cpu-freq.nix index 3df9b58c524..02f269f28f9 100644 --- a/nixos/modules/tasks/cpu-freq.nix +++ b/nixos/modules/tasks/cpu-freq.nix @@ -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 ]; - - jobs.cpufreq = - { description = "CPU Frequency Governor Setup"; - - after = [ "systemd-modules-load.service" ]; - wantedBy = [ "multi-user.target" ]; - - unitConfig.ConditionPathIsReadWrite = "/sys/devices/"; + boot.kernelModules = [ "acpi-cpufreq" "speedstep-lib" "pcc-cpufreq" + "cpufreq_${cfg.cpuFreqGovernor}" + ]; - path = [ pkgs.cpufrequtils ]; + environment.systemPackages = [ cpupower ]; - 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"; }; - }; + }; + }; } |