mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-18 15:56:50 +01:00
54 lines
1.3 KiB
Nix
54 lines
1.3 KiB
Nix
{ config, lib, pkgs, ... }:
|
|
|
|
with lib;
|
|
|
|
let
|
|
cpupower = config.boot.kernelPackages.cpupower;
|
|
cfg = config.powerManagement;
|
|
in
|
|
|
|
{
|
|
###### interface
|
|
|
|
options = {
|
|
|
|
powerManagement.cpuFreqGovernor = mkOption {
|
|
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 ];
|
|
unitConfig.ConditionVirtualization = false;
|
|
serviceConfig = {
|
|
Type = "oneshot";
|
|
RemainAfterExit = "yes";
|
|
ExecStart = "${cpupower}/bin/cpupower frequency-set -g ${cfg.cpuFreqGovernor}";
|
|
SuccessExitStatus = "0 237";
|
|
};
|
|
};
|
|
|
|
};
|
|
}
|