From 38494003cc53d5370dc2252790cfc6680117d9ae Mon Sep 17 00:00:00 2001 From: Crony Akatsuki Date: Thu, 30 Jan 2025 12:23:59 +0100 Subject: [PATCH] Add auto-cpufreq for power management. --- flake.lock | 21 +++++++++++++++++++++ flake.nix | 9 +++++++++ hosts/nixos/configuration.nix | 17 +++++++++++++++++ 3 files changed, 47 insertions(+) diff --git a/flake.lock b/flake.lock index 1252ebf..ed8620e 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,25 @@ { "nodes": { + "auto-cpufreq": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1737497253, + "narHash": "sha256-sOLwi/3oQiNWA2I3WiGneK988YdKVHbH1P5lEjxypIg=", + "owner": "AdnanHodzic", + "repo": "auto-cpufreq", + "rev": "4cee388c1bbea3adc333b597717d5d8d12375705", + "type": "github" + }, + "original": { + "owner": "AdnanHodzic", + "repo": "auto-cpufreq", + "type": "github" + } + }, "base16": { "inputs": { "fromYaml": "fromYaml" @@ -3231,6 +3251,7 @@ }, "root": { "inputs": { + "auto-cpufreq": "auto-cpufreq", "home-manager": "home-manager", "nixpkgs": "nixpkgs", "nvf": "nvf", diff --git a/flake.nix b/flake.nix index 41e6437..b38d6cd 100644 --- a/flake.nix +++ b/flake.nix @@ -19,12 +19,19 @@ url = "github:notashelf/nvf"; inputs.nixpkgs.follows = "nixpkgs"; }; + + # auto-cpufreq latest version, for optimizing my laptop's thermal's + auto-cpufreq = { + url = "github:AdnanHodzic/auto-cpufreq"; + inputs.nixpkgs.follows = "nixpkgs"; + }; }; outputs = { self, nixpkgs, home-manager, + auto-cpufreq, ... } @ inputs: { nixosConfigurations.nixos = nixpkgs.lib.nixosSystem { @@ -34,6 +41,8 @@ ./hosts/nixos/configuration.nix # Enable stylix inputs.stylix.nixosModules.stylix + # Load updated auto-cpufreq + auto-cpufreq.nixosModules.default # Load my modules ./modules/nixos # Setup home manager for my user diff --git a/hosts/nixos/configuration.nix b/hosts/nixos/configuration.nix index ec90abf..b88f8d4 100644 --- a/hosts/nixos/configuration.nix +++ b/hosts/nixos/configuration.nix @@ -95,6 +95,23 @@ options = ["_netdev" "noauto" "x-systemd.automount" "x-systemd.mount-timeout=10" "timeo=14" "x-systemd.idle-timeout=600"]; }; + # Setup auto-cpufreq + programs.auto-cpufreq = { + enable = true; + + settings = { + battery = { + governor = "powersave"; + turbo = "never"; + }; + + charger = { + governor = "performance"; + turbo = "auto"; + }; + }; + }; + # Allow for wireguard traffic networking.firewall = { # if packets are still dropped, they will show up in dmesg