From a87750cd30a1385986b58df59d3c0cf5090d5293 Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Sun, 9 Jun 2024 20:51:23 +0100 Subject: [PATCH] Tweak performance and battery optimisation settings Based on https://github.com/MatthewCroughan/nixcfg and other sources. --- lib/nixos/configuration.nix | 17 +++++++++++++++++ lib/nixos/hardware-configuration.nix | 11 +++++++++-- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/lib/nixos/configuration.nix b/lib/nixos/configuration.nix index 3d0bf11..e012ac5 100644 --- a/lib/nixos/configuration.nix +++ b/lib/nixos/configuration.nix @@ -26,6 +26,23 @@ in { boot.loader.efi.canTouchEfiVariables = true; boot.loader.efi.efiSysMountPoint = "/boot/efi"; + services.thermald.enable = true; + services.power-profiles-daemon.enable = false; + + services.tlp = { + enable = true; + + settings = { + PCIE_ASPM_ON_BAT = "powersupersave"; + CPU_SCALING_GOVERNOR_ON_AC = "performance"; + CPU_SCALING_GOVERNOR_ON_BAT = "powersave"; + CPU_MAX_PERF_ON_AC = "100"; + CPU_MAX_PERF_ON_BAT = "30"; + STOP_CHARGE_THRESH_BAT1 = "95"; + STOP_CHARGE_THRESH_BAT0 = "95"; + }; + }; + systemd.extraConfig = '' DefaultTimeoutStopSec=10s ''; diff --git a/lib/nixos/hardware-configuration.nix b/lib/nixos/hardware-configuration.nix index 69d1e45..e9fe2e5 100644 --- a/lib/nixos/hardware-configuration.nix +++ b/lib/nixos/hardware-configuration.nix @@ -5,10 +5,17 @@ [ "xhci_pci" "thunderbolt" "nvme" "usb_storage" "sd_mod" ]; boot.initrd.kernelModules = [ ]; boot.kernelModules = [ "kvm-intel" ]; - boot.kernelParams = [ "i8042.reset" ]; + boot.kernelParams = [ + "i915.modeset=1" + "i915.fastboot=1" + "i915.enable_guc=2" + "i915.enable_psr=1" + "i915.enable_fbc=1" + "i915.enable_dc=2" + ]; boot.extraModulePackages = [ ]; - boot.kernelPackages = pkgs.linuxPackages_latest; + boot.kernelPackages = pkgs.linuxPackages_zen; hardware.enableAllFirmware = true; fileSystems."/" = {