From c6008b53872a0a7b0e0d5d1f410bf62ce9e4e5e6 Mon Sep 17 00:00:00 2001 From: Antoine Viallon Date: Thu, 20 Apr 2023 19:05:51 +0200 Subject: [PATCH] [Hardware/Intel] Add throttled and thermald to improve performance and reduce thermal issues --- hardware/intel/cpu.nix | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/hardware/intel/cpu.nix b/hardware/intel/cpu.nix index 6d0609a..85701e3 100644 --- a/hardware/intel/cpu.nix +++ b/hardware/intel/cpu.nix @@ -2,10 +2,23 @@ with lib; let generalCfg = config.aviallon.general; + throttledService = "lenovo_fix"; in { config = mkIf (generalCfg.cpuVendor == "intel") { aviallon.boot.cmdline = { "intel_pstate" = "passive"; }; + + services.throttled.enable = generalCfg.unsafeOptimizations; + services.thermald.enable = !generalCfg.unsafeOptimizations; + + systemd.services.${throttledService} = { + bindsTo = [ "ac-power.target" ]; + conflicts = [ "thermald.service" ]; + }; + + systemd.services.thermald = { + wantedBy = [ "battery-power.target" ]; + }; }; }