Merge pull request #53301 from cdepillabout/remove-cpufreqgov-alias

nixos/cpufreq: Remove the alias to set the cpu frequency governor
This commit is contained in:
Silvan Mosberger 2019-01-03 17:47:53 +01:00 committed by GitHub
commit 2b1c9fd8a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 33 additions and 41 deletions

View File

@ -408,16 +408,6 @@
from nixpkgs due to the lack of maintainers. from nixpkgs due to the lack of maintainers.
</para> </para>
</listitem> </listitem>
<listitem>
<para>
The <option>powerManagement.cpuFreqGovernor</option> option has been
aliased to <option>powerManagement.cpufreq.governor</option>. On laptops,
<option>powerManagement.cpuFreqGovernor</option> is sometimes set in
<literal>/etc/nixos/hardware-configuration.nix</literal>, so you can
rename it to the new name, or run
<literal>nixos-generate-config</literal> again.
</para>
</listitem>
</itemizedlist> </itemizedlist>
</section> </section>
</section> </section>

View File

@ -104,7 +104,7 @@ if (-e "/sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors") {
foreach $e (@desired_governors) { foreach $e (@desired_governors) {
if (index($governors, $e) != -1) { if (index($governors, $e) != -1) {
last if (push @attrs, "powerManagement.cpufreq.governor = lib.mkDefault \"$e\";"); last if (push @attrs, "powerManagement.cpuFreqGovernor = lib.mkDefault \"$e\";");
} }
} }
} }

View File

@ -286,9 +286,6 @@ with lib;
(mkRenamedOptionModule [ "hardware" "ckb" "enable" ] [ "hardware" "ckb-next" "enable" ]) (mkRenamedOptionModule [ "hardware" "ckb" "enable" ] [ "hardware" "ckb-next" "enable" ])
(mkRenamedOptionModule [ "hardware" "ckb" "package" ] [ "hardware" "ckb-next" "package" ]) (mkRenamedOptionModule [ "hardware" "ckb" "package" ] [ "hardware" "ckb-next" "package" ])
# cpufeq
(mkAliasOptionModule [ "powerManagement" "cpuFreqGovernor" ] [ "powerManagement" "cpufreq" "governor" ])
] ++ (flip map [ "blackboxExporter" "collectdExporter" "fritzboxExporter" ] ++ (flip map [ "blackboxExporter" "collectdExporter" "fritzboxExporter"
"jsonExporter" "minioExporter" "nginxExporter" "nodeExporter" "jsonExporter" "minioExporter" "nginxExporter" "nodeExporter"
"snmpExporter" "unifiExporter" "varnishExporter" ] "snmpExporter" "unifiExporter" "varnishExporter" ]

View File

@ -55,7 +55,7 @@ in
config = mkIf cfg.enable { config = mkIf cfg.enable {
powerManagement.scsiLinkPolicy = null; powerManagement.scsiLinkPolicy = null;
powerManagement.cpufreq.governor = null; powerManagement.cpuFreqGovernor = null;
powerManagement.cpufreq.max = null; powerManagement.cpufreq.max = null;
powerManagement.cpufreq.min = null; powerManagement.cpufreq.min = null;

View File

@ -4,28 +4,32 @@ with lib;
let let
cpupower = config.boot.kernelPackages.cpupower; cpupower = config.boot.kernelPackages.cpupower;
cfg = config.powerManagement.cpufreq; cfg = config.powerManagement;
in in
{ {
###### interface ###### interface
options.powerManagement.cpufreq = { options.powerManagement = {
governor = mkOption { # TODO: This should be aliased to powerManagement.cpufreq.governor.
# https://github.com/NixOS/nixpkgs/pull/53041#commitcomment-31825338
cpuFreqGovernor = mkOption {
type = types.nullOr types.str; type = types.nullOr types.str;
default = null; default = null;
example = "ondemand"; example = "ondemand";
description = '' description = ''
Configure the governor used to regulate the frequence of the Configure the governor used to regulate the frequence of the
available CPUs. By default, the kernel configures the available CPUs. By default, the kernel configures the
performance governor, although this may be overwriten in your performance governor, although this may be overwritten in your
hardware-configuration.nix file. hardware-configuration.nix file.
Often used values: "ondemand", "powersave", "performance" Often used values: "ondemand", "powersave", "performance"
''; '';
}; };
cpufreq = {
max = mkOption { max = mkOption {
type = types.nullOr types.ints.unsigned; type = types.nullOr types.ints.unsigned;
default = null; default = null;
@ -43,6 +47,7 @@ in
The minimum frequency the CPU will use. The minimum frequency the CPU will use.
''; '';
}; };
};
}; };
@ -51,16 +56,16 @@ in
config = config =
let let
governorEnable = cfg.governor != null; governorEnable = cfg.cpuFreqGovernor != null;
maxEnable = cfg.max != null; maxEnable = cfg.cpufreq.max != null;
minEnable = cfg.min != null; minEnable = cfg.cpufreq.min != null;
enable = enable =
!config.boot.isContainer && !config.boot.isContainer &&
(governorEnable || maxEnable || minEnable); (governorEnable || maxEnable || minEnable);
in in
mkIf enable { mkIf enable {
boot.kernelModules = optional governorEnable "cpufreq_${cfg.governor}"; boot.kernelModules = optional governorEnable "cpufreq_${cfg.cpuFreqGovernor}";
environment.systemPackages = [ cpupower ]; environment.systemPackages = [ cpupower ];
@ -74,9 +79,9 @@ in
Type = "oneshot"; Type = "oneshot";
RemainAfterExit = "yes"; RemainAfterExit = "yes";
ExecStart = "${cpupower}/bin/cpupower frequency-set " + ExecStart = "${cpupower}/bin/cpupower frequency-set " +
optionalString governorEnable "--governor ${cfg.governor} " + optionalString governorEnable "--governor ${cfg.cpuFreqGovernor} " +
optionalString maxEnable "--max ${toString cfg.max} " + optionalString maxEnable "--max ${toString cfg.cpufreq.max} " +
optionalString minEnable "--min ${toString cfg.min} "; optionalString minEnable "--min ${toString cfg.cpufreq.min} ";
SuccessExitStatus = "0 237"; SuccessExitStatus = "0 237";
}; };
}; };