2011-12-17 00:44:37 +01:00
|
|
|
{ config, pkgs, ... }:
|
|
|
|
|
|
|
|
with pkgs.lib;
|
|
|
|
|
|
|
|
{
|
|
|
|
###### interface
|
|
|
|
|
|
|
|
options = {
|
2011-12-20 23:44:58 +01:00
|
|
|
|
|
|
|
powerManagement.cpuFreqGovernor = mkOption {
|
2011-12-17 00:44:37 +01:00
|
|
|
default = "";
|
|
|
|
example = "ondemand";
|
2012-01-13 14:26:52 +01:00
|
|
|
type = types.uniq types.string;
|
2011-12-17 00:44:37 +01:00
|
|
|
description = ''
|
|
|
|
Configure the governor used to regulate the frequence of the
|
|
|
|
available CPUs. By default, the kernel configures the governor
|
|
|
|
"userspace".
|
|
|
|
'';
|
|
|
|
};
|
2011-12-20 23:44:58 +01:00
|
|
|
|
2011-12-17 00:44:37 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
###### implementation
|
|
|
|
|
2011-12-20 23:44:58 +01:00
|
|
|
config = mkIf (config.powerManagement.cpuFreqGovernor != "") {
|
|
|
|
|
|
|
|
environment.systemPackages = [ pkgs.cpufrequtils ];
|
|
|
|
|
|
|
|
jobs.cpufreq =
|
2011-12-17 00:44:37 +01:00
|
|
|
{ description = "Initialize CPU frequency governor";
|
|
|
|
|
|
|
|
startOn = "started udev";
|
|
|
|
|
|
|
|
task = true;
|
|
|
|
|
|
|
|
script = ''
|
|
|
|
for i in $(seq 0 $(($(nproc) - 1))); do
|
2011-12-20 23:44:58 +01:00
|
|
|
${pkgs.cpufrequtils}/bin/cpufreq-set -g ${config.powerManagement.cpuFreqGovernor} -c $i
|
2011-12-17 00:44:37 +01:00
|
|
|
done
|
|
|
|
'';
|
|
|
|
};
|
2011-12-20 23:44:58 +01:00
|
|
|
|
|
|
|
};
|
2011-12-17 00:44:37 +01:00
|
|
|
|
|
|
|
}
|