Author: simons
Date: Fri Dec 16 23:44:37 2011
New Revision: 30949
URL: https://nixos.org/websvn/nix/?rev=30949&sc=1

Log:
Added cpuFreqGovernor option to configure a CPU frequency governor.

Added:
   nixos/trunk/modules/tasks/cpu-freq.nix
Modified:
   nixos/trunk/modules/module-list.nix

Modified: nixos/trunk/modules/module-list.nix
==============================================================================
--- nixos/trunk/modules/module-list.nix Fri Dec 16 23:33:01 2011        (r30948)
+++ nixos/trunk/modules/module-list.nix Fri Dec 16 23:44:37 2011        (r30949)
@@ -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

Added: nixos/trunk/modules/tasks/cpu-freq.nix
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ nixos/trunk/modules/tasks/cpu-freq.nix      Fri Dec 16 23:44:37 2011        
(r30949)
@@ -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
+        '';
+      };
+  });
+
+}
_______________________________________________
nix-commits mailing list
[email protected]
http://lists.science.uu.nl/mailman/listinfo/nix-commits

Reply via email to