From 43fe882270f9d2abdc61736ca88efc7362bcad73 Mon Sep 17 00:00:00 2001 From: Don Harper Date: Thu, 21 Aug 2025 13:39:59 -0500 Subject: [PATCH] hosts | add auto-cpufreq, switch loki & smaug to use, formating --- hosts/loki/default.nix | 14 +++++++++++--- hosts/smaug/default.nix | 12 ++++++++++-- hosts/vars.nix | 4 ++-- hosts/workstation/auto-cpufreq.nix | 30 ++++++++++++++++++++++++++++++ hosts/workstation/default.nix | 1 + 5 files changed, 54 insertions(+), 7 deletions(-) create mode 100644 hosts/workstation/auto-cpufreq.nix diff --git a/hosts/loki/default.nix b/hosts/loki/default.nix index f5df8e2..52cd7b6 100644 --- a/hosts/loki/default.nix +++ b/hosts/loki/default.nix @@ -1,4 +1,11 @@ -{ inputs, outputs, lib, config, pkgs, ... }: { +{ + inputs, + outputs, + lib, + config, + pkgs, + ... +}: { imports = [ inputs.nixos-hardware.nixosModules.dell-xps-13-9310 ./hardware-configuration.nix @@ -6,7 +13,7 @@ ../workstation ]; networking.hostName = "loki"; - boot.binfmt.emulatedSystems = [ "aarch64-linux" ]; + boot.binfmt.emulatedSystems = ["aarch64-linux"]; variables.address = "100.72.0.1"; variables.swayScale = "1.1"; @@ -18,7 +25,8 @@ kvm.enable = false; games.enable = true; wine.enable = false; - tlp.enable = true; + tlp.enable = false; + auto-cpufreq.enable = true; gnome-calendar.enable = true; }; wm = { diff --git a/hosts/smaug/default.nix b/hosts/smaug/default.nix index 5dbedeb..5cef073 100644 --- a/hosts/smaug/default.nix +++ b/hosts/smaug/default.nix @@ -1,4 +1,11 @@ -{ inputs, outputs, lib, config, pkgs, ... }: { +{ + inputs, + outputs, + lib, + config, + pkgs, + ... +}: { imports = [ inputs.nixos-hardware.nixosModules.lenovo-thinkpad-x260 inputs.nixos-hardware.nixosModules.common-pc-laptop @@ -19,7 +26,8 @@ kvm.enable = true; games.enable = true; wine.enable = false; - tlp.enable = true; + tlp.enable = false; + auto-cpufreq = true; gnome-calendar.enable = true; }; wm = { diff --git a/hosts/vars.nix b/hosts/vars.nix index ee8dc05..9480aa4 100644 --- a/hosts/vars.nix +++ b/hosts/vars.nix @@ -1,8 +1,8 @@ -{ lib, ... }: { +{lib, ...}: { options = { variables = lib.mkOption { type = lib.types.attrs; - default = { }; + default = {}; }; }; } diff --git a/hosts/workstation/auto-cpufreq.nix b/hosts/workstation/auto-cpufreq.nix new file mode 100644 index 0000000..c2d0ac1 --- /dev/null +++ b/hosts/workstation/auto-cpufreq.nix @@ -0,0 +1,30 @@ +{ + pkgs, + inputs, + config, + lib, + ... +}: +with lib; let + cfg = config.roles.auto-cpufreq; +in { + options.roles.auto-cpufreq = {enable = mkEnableOption "roles auto-cpufreq";}; + config = mkIf cfg.enable { + services.auto-cpufreq = { + enable = true; + settings = { + battery = { + governor = "powersave"; + turbo = "never"; + enable_thresholds = true; + start_threshold = 50; + stop_threshold = 80; + }; + charger = { + governor = "performance"; + turbo = "auto"; + }; + }; + }; + }; +} diff --git a/hosts/workstation/default.nix b/hosts/workstation/default.nix index a084f70..633033f 100644 --- a/hosts/workstation/default.nix +++ b/hosts/workstation/default.nix @@ -48,6 +48,7 @@ in { ./detect-reboot-needed.nix ./kmscon.nix ./systemd.nix + ./auto-cpufreq.nix ./tlp.nix ./upgrade-diff.nix ./wine.nix