mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-01 07:01:54 +00:00
cpu-freq: Try powersave if ondemand is not available
This commit is contained in:
parent
b20fdff521
commit
4dc56db37e
@ -69,8 +69,8 @@ in
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
|
||||
# FIXME: Implement powersave governor for sandy bridge or later Intel CPUs
|
||||
powerManagement.cpuFreqGovernor = mkDefault "ondemand";
|
||||
# ondemand governor is not available on sandy bridge or later Intel CPUs
|
||||
powerManagement.cpuFreqGovernor = mkDefault [ "ondemand" "powersave" ];
|
||||
|
||||
systemd.targets.post-resume = {
|
||||
description = "Post-Resume Actions";
|
||||
|
@ -13,9 +13,9 @@ in
|
||||
options = {
|
||||
|
||||
powerManagement.cpuFreqGovernor = mkOption {
|
||||
type = types.nullOr types.str;
|
||||
default = null;
|
||||
example = "ondemand";
|
||||
type = types.listOf types.str;
|
||||
default = [];
|
||||
example = [ "ondemand" ];
|
||||
description = ''
|
||||
Configure the governor used to regulate the frequence of the
|
||||
available CPUs. By default, the kernel configures the
|
||||
@ -28,9 +28,9 @@ in
|
||||
|
||||
###### implementation
|
||||
|
||||
config = mkIf (!config.boot.isContainer && config.powerManagement.cpuFreqGovernor != null) {
|
||||
config = mkIf (!config.boot.isContainer && config.powerManagement.cpuFreqGovernor != []) {
|
||||
|
||||
boot.kernelModules = [ "cpufreq_${cfg.cpuFreqGovernor}" ];
|
||||
boot.kernelModules = map (x: "cpufreq_" + x) cfg.cpuFreqGovernor;
|
||||
|
||||
environment.systemPackages = [ cpupower ];
|
||||
|
||||
@ -43,7 +43,12 @@ in
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
RemainAfterExit = "yes";
|
||||
ExecStart = "${cpupower}/bin/cpupower frequency-set -g ${cfg.cpuFreqGovernor}";
|
||||
ExecStart = ''
|
||||
${pkgs.bash}/bin/sh -c \
|
||||
"for i in ${toString cfg.cpuFreqGovernor}; do \
|
||||
${cpupower}/bin/cpupower frequency-set -g $i && break; \
|
||||
done"
|
||||
'';
|
||||
SuccessExitStatus = "0 237";
|
||||
};
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user