From 8ed3a90cdfe99722aee1d158a7d9f9bfd63ce275 Mon Sep 17 00:00:00 2001 From: Maximilian Bosch Date: Sun, 28 Jan 2018 09:38:45 +0100 Subject: 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; }; } ``` --- nixos/modules/config/power-management.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'nixos/modules/config/power-management.nix') 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"; -- cgit 1.4.1