mirror of
https://github.com/SebastianWendel/nixpkgs.git
synced 2024-10-18 11:43:17 +02:00
dd209e901c
Additionally, put the powersave utility in charge of loading the cpufrequency modules based on the governor specified in the configuration.
55 lines
1.1 KiB
Nix
55 lines
1.1 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.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}
|
|
'';
|
|
serviceConfig = {
|
|
Type = "oneshot";
|
|
RemainAfterExit = "yes";
|
|
};
|
|
};
|
|
|
|
};
|
|
}
|