2014-04-14 14:26:48 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
2011-12-16 23:44:37 +00:00
|
|
|
|
2014-04-14 14:26:48 +00:00
|
|
|
with lib;
|
2011-12-16 23:44:37 +00:00
|
|
|
|
2014-03-17 23:07:46 +00:00
|
|
|
let
|
|
|
|
cpupower = config.boot.kernelPackages.cpupower;
|
|
|
|
cfg = config.powerManagement;
|
|
|
|
in
|
|
|
|
|
2011-12-16 23:44:37 +00:00
|
|
|
{
|
|
|
|
###### interface
|
|
|
|
|
|
|
|
options = {
|
2012-08-23 16:12:25 +00:00
|
|
|
|
2011-12-20 22:44:58 +00:00
|
|
|
powerManagement.cpuFreqGovernor = mkOption {
|
2013-10-30 16:37:45 +00:00
|
|
|
type = types.nullOr types.str;
|
|
|
|
default = null;
|
2011-12-16 23:44:37 +00:00
|
|
|
example = "ondemand";
|
|
|
|
description = ''
|
|
|
|
Configure the governor used to regulate the frequence of the
|
2013-01-24 12:55:59 +00:00
|
|
|
available CPUs. By default, the kernel configures the
|
|
|
|
on-demand governor.
|
2011-12-16 23:44:37 +00:00
|
|
|
'';
|
|
|
|
};
|
2012-08-23 16:12:25 +00:00
|
|
|
|
2011-12-16 23:44:37 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
###### implementation
|
|
|
|
|
2013-10-30 16:37:45 +00:00
|
|
|
config = mkIf (config.powerManagement.cpuFreqGovernor != null) {
|
2011-12-20 22:44:58 +00:00
|
|
|
|
2014-03-17 23:07:46 +00:00
|
|
|
boot.kernelModules = [ "acpi-cpufreq" "speedstep-lib" "pcc-cpufreq"
|
|
|
|
"cpufreq_${cfg.cpuFreqGovernor}"
|
|
|
|
];
|
2013-11-26 17:17:12 +00:00
|
|
|
|
2014-03-17 23:07:46 +00:00
|
|
|
environment.systemPackages = [ cpupower ];
|
2011-12-16 23:44:37 +00:00
|
|
|
|
2014-03-17 23:07:46 +00:00
|
|
|
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";
|
2011-12-16 23:44:37 +00:00
|
|
|
};
|
2014-03-17 23:07:46 +00:00
|
|
|
};
|
2011-12-16 23:44:37 +00:00
|
|
|
|
2014-03-17 23:07:46 +00:00
|
|
|
};
|
2011-12-16 23:44:37 +00:00
|
|
|
}
|