TZ: set a default
[julm/julm-nix.git] / nixos / profiles / tlp.nix
index 8dccace211c8a99643278f1f01966bbf124c6538..02e7c603f41a884acffcbbc721c2416e466e9d35 100644 (file)
@@ -1,11 +1,18 @@
-{ config, lib, pkgs, ... }:
+{ lib, config, ... }:
 with lib;
 {
-services.tlp = {
-  enable = true;
-  settings = {
-    CPU_SCALING_GOVERNOR_ON_AC = "ondemand";
-    CPU_SCALING_GOVERNOR_ON_BAT = "powersave";
+  # Preloading the kernel modules to avoid:
+  # tlp: Error in configuration at CPU_SCALING_GOVERNOR_ON_BAT="powersave": governor not available. Skipped.
+  boot.initrd.kernelModules = [
+    "cpufreq_ondemand"
+    "cpufreq_powersave"
+  ];
+  services.tlp = {
+    # Gnome 40 introduced a new way of managing power, without tlp.
+    enable = mkDefault (!config.services.power-profiles-daemon.enable);
+    settings = {
+      CPU_SCALING_GOVERNOR_ON_AC = "ondemand";
+      CPU_SCALING_GOVERNOR_ON_BAT = "powersave";
+    };
   };
-};
 }