diff --git a/flake.lock b/flake.lock index 1e251fd..dcaaea6 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,25 @@ { "nodes": { + "auto-cpufreq": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1730737631, + "narHash": "sha256-YsAImsJDFpkW+z45/rj/vceZ8C48gv9RUpnakpc+q5c=", + "owner": "AdnanHodzic", + "repo": "auto-cpufreq", + "rev": "18a3a93f62f2572bc8ed8e953d09dca4a87da9bc", + "type": "github" + }, + "original": { + "owner": "AdnanHodzic", + "repo": "auto-cpufreq", + "type": "github" + } + }, "crane": { "inputs": { "nixpkgs": [ @@ -355,6 +375,7 @@ }, "root": { "inputs": { + "auto-cpufreq": "auto-cpufreq", "home-manager": "home-manager", "lanzaboote": "lanzaboote", "lib": "lib", diff --git a/flake.nix b/flake.nix index e698fae..7d70261 100644 --- a/flake.nix +++ b/flake.nix @@ -35,10 +35,17 @@ # NixOS hardware quirks nixos-hardware.url = "github:NixOS/nixos-hardware/master"; + + # Power management via auto-cpufreq + auto-cpufreq = { + url = "github:AdnanHodzic/auto-cpufreq"; + inputs.nixpkgs.follows = "nixpkgs"; + }; }; outputs = inputs@{ + auto-cpufreq, home-manager, lanzaboote, lix-module, @@ -58,6 +65,7 @@ # Define shared modules and imports defaultModules = [ ./modules/autoimport.nix + auto-cpufreq.nixosModules.default lix-module.nixosModules.default lanzaboote.nixosModules.lanzaboote nix-flatpak.nixosModules.nix-flatpak diff --git a/hosts/Khanda/default.nix b/hosts/Khanda/default.nix index 4ade509..027ff9e 100644 --- a/hosts/Khanda/default.nix +++ b/hosts/Khanda/default.nix @@ -41,6 +41,8 @@ in # Enable GPU support. gpu.intel.enable = true; + powerManagement.enable = true; + # Enable support for primary RAID array (just in case) raid.storage.enable = true; diff --git a/hosts/Shura/default.nix b/hosts/Shura/default.nix index 32f703d..c4cfa50 100644 --- a/hosts/Shura/default.nix +++ b/hosts/Shura/default.nix @@ -53,6 +53,8 @@ in # Keep old generations for two weeks. retentionPeriod = "14d"; + powerManagement.enable = true; + services = { # Run daily automatic updates. autoUpgrade = { diff --git a/modules/system/system.nix b/modules/system/system.nix index e55b807..0262384 100644 --- a/modules/system/system.nix +++ b/modules/system/system.nix @@ -37,12 +37,18 @@ in xz.bin ]; }; + + powerManagement.enable = lib.mkEnableOption "Enables power management, e.g. for laptops."; }; }; config = { # Install base packages environment.systemPackages = cfg.corePackages ++ cfg.packages; + # Configure power management via auto-cpufreq + # https://github.com/AdnanHodzic/auto-cpufreq + programs.auto-cpufreq.enable = cfg.powerManagement.enable; + services = { # Automatically set the timezone based on location automatic-timezoned.enable = true;