nixpkgs/modules/tasks/cpu-freq.nix
Eelco Dolstra cf36b3db80 * If power management is enabled, set the governor to ‘ondemand’ by
default.  See
  
    http://www.codon.org.uk/~mjg59/power/good_practices.html
    
  for the reasoning.  (Basically, the ‘performance’ and ‘powersave’
  governors don't actually provide extra performance or power savings
  in most cases.)

  It used to be that desktop environments like KDE were able to set
  the governor through HAL (e.g. KDE could be configured to switch to
  the powersave governor when the user unplugs his laptop).  However,
  this is no longer the case with upower — it is now expected that
  everybody uses the ondemand governor.  See

    http://old.nabble.com/-PATCH--powerdevil-remove-cpufreq.patch-td27815354.html

* Rename ‘cpuFreqGovernor’ to ‘powerManagement.cpuFreqGovernor’.

* Include cpufreq-utils in the system path if a governor is set, since
  we depend on it anyway.

svn path=/nixos/trunk/; revision=30991
2011-12-20 22:44:58 +00:00

45 lines
894 B
Nix

{ config, pkgs, ... }:
with pkgs.lib;
{
###### interface
options = {
powerManagement.cpuFreqGovernor = mkOption {
default = "";
example = "ondemand";
description = ''
Configure the governor used to regulate the frequence of the
available CPUs. By default, the kernel configures the governor
"userspace".
'';
};
};
###### implementation
config = mkIf (config.powerManagement.cpuFreqGovernor != "") {
environment.systemPackages = [ pkgs.cpufrequtils ];
jobs.cpufreq =
{ description = "Initialize CPU frequency governor";
startOn = "started udev";
task = true;
script = ''
for i in $(seq 0 $(($(nproc) - 1))); do
${pkgs.cpufrequtils}/bin/cpufreq-set -g ${config.powerManagement.cpuFreqGovernor} -c $i
done
'';
};
};
}