9e5bbee2b1
Otherwise it will be restarted by switch-to-configuration even when it hasn't changed.
44 lines
905 B
Nix
44 lines
905 B
Nix
{ config, pkgs, ... }:
|
|
|
|
with pkgs.lib;
|
|
|
|
{
|
|
###### interface
|
|
|
|
options = {
|
|
|
|
powerManagement.cpuFreqGovernor = mkOption {
|
|
default = "";
|
|
example = "ondemand";
|
|
type = types.uniq types.string;
|
|
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.powerManagement.cpuFreqGovernor != "") {
|
|
|
|
environment.systemPackages = [ pkgs.cpufrequtils ];
|
|
|
|
jobs.cpufreq =
|
|
{ description = "Initialize CPU frequency governor";
|
|
|
|
startOn = "started udev";
|
|
|
|
preStart = ''
|
|
for i in $(seq 0 $(($(nproc) - 1))); do
|
|
${pkgs.cpufrequtils}/bin/cpufreq-set -g ${config.powerManagement.cpuFreqGovernor} -c $i
|
|
done
|
|
'';
|
|
};
|
|
};
|
|
|
|
}
|