From 13f46e06dee8e7efdbeeb8973e5b0a99c46184b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vili=20Sinerv=C3=A4?= Date: Thu, 21 Nov 2024 14:25:33 +0200 Subject: [PATCH] Refactor laptop conf --- hardware-specific/amd-laptop.nix | 13 +++---------- hardware-specific/laptop.nix | 33 ++++++++++++++++++++++++++++++++ machine-confs/helium.nix | 2 -- machine-confs/lithium.nix | 3 +-- 4 files changed, 37 insertions(+), 14 deletions(-) create mode 100644 hardware-specific/laptop.nix diff --git a/hardware-specific/amd-laptop.nix b/hardware-specific/amd-laptop.nix index e19b357..1dbcd3b 100644 --- a/hardware-specific/amd-laptop.nix +++ b/hardware-specific/amd-laptop.nix @@ -1,5 +1,7 @@ { config, pkgs, ... }: { + imports = [ ./laptop.nix ]; + environment.systemPackages = with pkgs; [ zenmonitor ]; hardware.opengl.extraPackages = with pkgs; [ rocmPackages.clr.icd ]; @@ -7,15 +9,6 @@ boot.initrd.kernelModules = [ "amdgpu" ]; services = { - xserver = pkgs.lib.mkIf config.services.xserver.enable { - videoDrivers = [ - "amdgpu" - "modesetting" - ]; - deviceSection = '' - Option "DRI" "2" - Option "TearFree" "true" - ''; - }; + xserver = pkgs.lib.mkIf config.services.xserver.enable { videoDrivers = [ "amdgpu" ]; }; }; } diff --git a/hardware-specific/laptop.nix b/hardware-specific/laptop.nix new file mode 100644 index 0000000..00963e8 --- /dev/null +++ b/hardware-specific/laptop.nix @@ -0,0 +1,33 @@ +{ config, pkgs, ... }: +{ + services = { + xserver = pkgs.lib.mkIf config.services.xserver.enable { + videoDrivers = [ "modesetting" ]; + deviceSection = '' + Option "DRI" "2" + Option "TearFree" "true" + ''; + }; + }; + + services.tlp = { + enable = true; + settings = { + CPU_SCALING_GOVERNOR_ON_AC = "performance"; + CPU_SCALING_GOVERNOR_ON_BAT = "powersave"; + + CPU_ENERGY_PERF_POLICY_ON_BAT = "power"; + CPU_ENERGY_PERF_POLICY_ON_AC = "performance"; + + CPU_MIN_PERF_ON_AC = 0; + CPU_MAX_PERF_ON_AC = 100; + CPU_MIN_PERF_ON_BAT = 0; + CPU_MAX_PERF_ON_BAT = 40; + + #Optional helps save long term battery health + START_CHARGE_THRESH_BAT0 = 60; # 60 and bellow it starts to charge + STOP_CHARGE_THRESH_BAT0 = 80; # 80 and above it stops charging + + }; + }; +} diff --git a/machine-confs/helium.nix b/machine-confs/helium.nix index e006456..9966dab 100644 --- a/machine-confs/helium.nix +++ b/machine-confs/helium.nix @@ -79,8 +79,6 @@ ../hardware-specific/usb-automount.nix ]; - services.tlp.enable = true; - services.xserver.displayManager.setupCommands = '' ${pkgs.xorg.xrandr}/bin/xrandr --output DisplayPort-0 --auto --pos 0x0 --primary --output eDP --auto --pos 3840x360 ''; diff --git a/machine-confs/lithium.nix b/machine-confs/lithium.nix index 9c0b5c5..0e637f5 100644 --- a/machine-confs/lithium.nix +++ b/machine-confs/lithium.nix @@ -57,10 +57,9 @@ ../hardware-specific/keychron-q11.nix ../hardware-specific/trackball.nix ../hardware-specific/usb-automount.nix + ../hardware-specific/laptop.nix ]; - services.tlp.enable = true; - system.autoUpgrade.allowReboot = pkgs.lib.mkForce false; swapDevices = pkgs.lib.mkForce [