1
0
Fork 0
mirror of https://github.com/NixOS/nixpkgs synced 2024-10-19 03:47:13 -04:00
nixpkgs/nixos/modules/tasks/cpu-freq.nix

56 lines
1.2 KiB
Nix
Raw Normal View History

{ config, lib, pkgs, ... }:
with lib;
let
cpupower = config.boot.kernelPackages.cpupower;
cfg = config.powerManagement;
in
{
###### interface
options = {
powerManagement.cpuFreqGovernor = mkOption {
2013-10-30 12:37:45 -04:00
type = types.nullOr types.str;
default = null;
example = "ondemand";
description = ''
Configure the governor used to regulate the frequence of the
available CPUs. By default, the kernel configures the
on-demand governor.
'';
};
};
###### implementation
config = mkIf (!config.boot.isContainer && config.powerManagement.cpuFreqGovernor != null) {
boot.kernelModules = [ "acpi-cpufreq" "speedstep-lib" "pcc-cpufreq"
"cpufreq_${cfg.cpuFreqGovernor}"
];
environment.systemPackages = [ cpupower ];
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}
'';
2014-04-16 04:36:16 -04:00
unitConfig.ConditionVirtualization = false;
serviceConfig = {
Type = "oneshot";
RemainAfterExit = "yes";
};
};
};
}