From 2c09c21833e0ccbdc80827f51c679c88f5de71a3 Mon Sep 17 00:00:00 2001 From: Jacob Bachmann Date: Thu, 5 Sep 2024 18:39:46 +0200 Subject: [PATCH] feat: add option for services.tlp.settings with defaults --- hosts/W530/default.nix | 23 +++++++++++++++++++++++ modules/default.nix | 24 ++++++++++++++++++++++++ modules/power.nix | 7 +------ 3 files changed, 48 insertions(+), 6 deletions(-) diff --git a/hosts/W530/default.nix b/hosts/W530/default.nix index c1ca0f2..3b9f144 100644 --- a/hosts/W530/default.nix +++ b/hosts/W530/default.nix @@ -11,6 +11,27 @@ bchmnn = { + power = { + tlp = { + settings = { + # performance | powersave + CPU_SCALING_GOVERNOR_ON_AC = "performance"; + CPU_SCALING_GOVERNOR_ON_BAT = "performance"; + # performance | balance_performance | default | balance_power | power + CPU_ENERGY_PERF_POLICY_ON_AC = "power"; + CPU_ENERGY_PERF_POLICY_ON_BAT = "power"; + # performance | balanced | low-power + PLATFORM_PROFILE_ON_AC = "low-power"; + PLATFORM_PROFILE_ON_BAT = "low-power"; + CPU_MIN_PERF_ON_AC = 0; + CPU_MAX_PERF_ON_AC = 100; + CPU_MIN_PERF_ON_BAT = 0; + CPU_MAX_PERF_ON_BAT = 100; + }; + }; + }; + + gui = { enable = true; greeter.enable = false; @@ -35,4 +56,6 @@ }; + services.logind.lidSwitch = "ignore"; + } diff --git a/modules/default.nix b/modules/default.nix index 3b0f2b2..fc887a3 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -3,6 +3,30 @@ # options affecting multiple modules options.bchmnn = with lib; { + power = { + tlp = { + settings = mkOption { + type = with types; attrsOf (oneOf [ bool int float str (listOf str) ]); + default = { + # performance | powersave + CPU_SCALING_GOVERNOR_ON_AC = "performance"; + CPU_SCALING_GOVERNOR_ON_BAT = "powersave"; + # performance | balance_performance | default | balance_power | power + CPU_ENERGY_PERF_POLICY_ON_AC = "performance"; + CPU_ENERGY_PERF_POLICY_ON_BAT = "power"; + # performance | balanced | low-power + PLATFORM_PROFILE_ON_AC = "performance"; + PLATFORM_PROFILE_ON_BAT = "low-power"; + CPU_MIN_PERF_ON_AC = 0; + CPU_MAX_PERF_ON_AC = 100; + CPU_MIN_PERF_ON_BAT = 0; + CPU_MAX_PERF_ON_BAT = 100; + }; + }; + }; + }; + + gui = { enable = mkEnableOption "gui"; greeter = { diff --git a/modules/power.nix b/modules/power.nix index b707fc2..8df4076 100644 --- a/modules/power.nix +++ b/modules/power.nix @@ -5,12 +5,7 @@ services.tlp = { enable = !builtins.elem "gnome" gui.flavour; - settings = { - CPU_ENERGY_PERF_POLICY_ON_AC = "performance"; - CPU_ENERGY_PERF_POLICY_ON_BAT = "balance_power"; - PLATFORM_PROFILE_ON_AC = "performance"; - PLATFORM_PROFILE_ON_BAT = "balanced"; - }; + settings = power.tlp.settings; }; environment.systemPackages = with pkgs; [