diff --git a/modules/module-list.nix b/modules/module-list.nix index a44e1c6e422..80f52be37f3 100644 --- a/modules/module-list.nix +++ b/modules/module-list.nix @@ -190,6 +190,7 @@ ./system/upstart-events/runlevel.nix ./system/upstart-events/shutdown.nix ./system/upstart/upstart.nix + ./tasks/cpu-freq.nix ./tasks/filesystems.nix ./tasks/kbd.nix ./tasks/lvm.nix diff --git a/modules/tasks/cpu-freq.nix b/modules/tasks/cpu-freq.nix new file mode 100644 index 00000000000..6498b45a635 --- /dev/null +++ b/modules/tasks/cpu-freq.nix @@ -0,0 +1,39 @@ +{ config, pkgs, ... }: + +with pkgs.lib; + +{ + ###### interface + + options = { + 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.cpuFreqGovernor != "") ({ + 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.cpuFreqGovernor} -c $i + done + ''; + }; + }); + +}