about summary refs log tree commit diff
path: root/nixos/modules/config/power-management.nix
diff options
context:
space:
mode:
authorMaximilian Bosch <maximilian@mbosch.me>2018-01-28 09:38:45 +0100
committerMaximilian Bosch <maximilian@mbosch.me>2018-01-28 09:38:45 +0100
commit8ed3a90cdfe99722aee1d158a7d9f9bfd63ce275 (patch)
tree74771e2ff99c0f56d55d7318c70e8e2f4ffbefe6 /nixos/modules/config/power-management.nix
parentfff0daddce4999f0bdd428ee64be40cd8c26152e (diff)
downloadnixlib-8ed3a90cdfe99722aee1d158a7d9f9bfd63ce275.tar
nixlib-8ed3a90cdfe99722aee1d158a7d9f9bfd63ce275.tar.gz
nixlib-8ed3a90cdfe99722aee1d158a7d9f9bfd63ce275.tar.bz2
nixlib-8ed3a90cdfe99722aee1d158a7d9f9bfd63ce275.tar.lz
nixlib-8ed3a90cdfe99722aee1d158a7d9f9bfd63ce275.tar.xz
nixlib-8ed3a90cdfe99722aee1d158a7d9f9bfd63ce275.tar.zst
nixlib-8ed3a90cdfe99722aee1d158a7d9f9bfd63ce275.zip
nixos/powerManagement: set `cpuFreqGovernor` with `mkOptionDefault`
`nixos-generate-config` detects the `cpuFreqGovernor` suited best for my
machine, e.g. `powerManagement.cpuFreqGovernor = lib.mkDefault "powersave";`.

However the `powerManagement` module sets a sensitive default for
`cpuFreqGovernor` using `mkDefault` to avoid breackage with older
setups. Since 140ac2f1 the `hardware-configuration.nix` sets the
gorvernor with `mkDefault` as well which causes evaluation errors if the
powermanagement module is enabled:

```
error: The unique option `powerManagement.cpuFreqGovernor' is defined multiple times, in `/home/ma27/Projects/nixos-config/hardware-configuration.nix' and `/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/nixos/modules/config/power-management.nix'.
```

Using `mkOptionDefault` rather than `mkDefault` in the powermanagement
module fixes this issue as it decreases the priority of the module and
prefers the value set in `hardware-configuration.nix`.

I have confirmed the change using the following VM declaration:

```
{
  cpuFreq = { lib, ... }: {
    powerManagement.cpuFreqGovernor = lib.mkDefault "powersave";
    powerManagement.enable = true;
  };
}
```
Diffstat (limited to 'nixos/modules/config/power-management.nix')
-rw-r--r--nixos/modules/config/power-management.nix2
1 files changed, 1 insertions, 1 deletions
diff --git a/nixos/modules/config/power-management.nix b/nixos/modules/config/power-management.nix
index a4a4d6e1a6af..7a5ce6ee5b99 100644
--- a/nixos/modules/config/power-management.nix
+++ b/nixos/modules/config/power-management.nix
@@ -70,7 +70,7 @@ in
   config = mkIf cfg.enable {
 
     # Leftover for old setups, should be set by nixos-generate-config now
-    powerManagement.cpuFreqGovernor = mkDefault "ondemand";
+    powerManagement.cpuFreqGovernor = mkOptionDefault "ondemand";
 
     systemd.targets.post-resume = {
       description = "Post-Resume Actions";