From a2d98282879821c36b11b839b6c062208a44f55c Mon Sep 17 00:00:00 2001 From: Sam Date: Mon, 18 Nov 2024 19:04:13 +0000 Subject: [PATCH 1/2] Update Telescope command and modify NixOS configurations - Update Telescope command in `telescope.nix` to use `grep_string` - Add `cpupower` and `lm_sensors` to `systemPackages` in `citadel/default.nix' - Enable power management for NVIDIA in `citadel/default.nix` and clean up udev rules formatting --- home/common/core/nixvim/plugins/telescope.nix | 2 +- hosts/citadel/default.nix | 46 ++++++++++--------- hosts/common/core/default.nix | 1 - 3 files changed, 26 insertions(+), 23 deletions(-) diff --git a/home/common/core/nixvim/plugins/telescope.nix b/home/common/core/nixvim/plugins/telescope.nix index 477e3ad..e35310a 100644 --- a/home/common/core/nixvim/plugins/telescope.nix +++ b/home/common/core/nixvim/plugins/telescope.nix @@ -22,7 +22,7 @@ # grep string under cursor mode = ["n"]; key = "fs"; - action = "Telescope string_grep"; + action = "Telescope grep_string"; options = {noremap = true;}; } { diff --git a/hosts/citadel/default.nix b/hosts/citadel/default.nix index 5c6a896..6a59938 100644 --- a/hosts/citadel/default.nix +++ b/hosts/citadel/default.nix @@ -108,6 +108,11 @@ in { XCURSOR_SIZE = "64"; }; + environment.systemPackages = [ + pkgs.linuxKernel.packages.linux_zen.cpupower + pkgs.lm_sensors + ]; + # services.tlp = { # enable = true; # settings = { @@ -135,7 +140,7 @@ in { enable = true; }; - services.xserver.videoDrivers = [ "nvidia" ]; + services.xserver.videoDrivers = ["nvidia"]; hardware.nvidia = { prime = { @@ -148,8 +153,8 @@ in { }; nvidiaPersistenced = true; modesetting.enable = true; - powerManagement.enable = false; - powerManagement.finegrained = false; + powerManagement.enable = true; + powerManagement.finegrained = true; open = false; nvidiaSettings = true; # FIXME issue with stable nvidia driver and latest linux kernel @@ -169,26 +174,25 @@ in { # https://discourse.nixos.org/t/how-to-use-nvidia-prime-offload-to-run-the-x-server-on-the-integrated-board/9091/15 # for udev rules to disable dGPU when not in use boot.extraModprobeConfig = '' - options nvidia NVreg_DynamicPowerManagement=0x02 options nvidia NVreg_EnableGpuFirmware=0 - ''; + ''; services.udev.extraRules = '' - # Remove NVIDIA USB xHCI Host Controller devices, if present - ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x0c0330", ATTR{remove}="1" - - # Remove NVIDIA USB Type-C UCSI devices, if present - ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x0c8000", ATTR{remove}="1" - - # Remove NVIDIA Audio devices, if present - ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x040300", ATTR{remove}="1" - - # Enable runtime PM for NVIDIA VGA/3D controller devices on driver bind - ACTION=="bind", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x030000", TEST=="power/control", ATTR{power/control}="auto" - ACTION=="bind", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x030200", TEST=="power/control", ATTR{power/control}="auto" - - # Disable runtime PM for NVIDIA VGA/3D controller devices on driver unbind - ACTION=="unbind", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x030000", TEST=="power/control", ATTR{power/control}="on" - ACTION=="unbind", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x030200", TEST=="power/control", ATTR{power/control}="on" + # Remove NVIDIA USB xHCI Host Controller devices, if present + ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x0c0330", ATTR{remove}="1" + + # Remove NVIDIA USB Type-C UCSI devices, if present + ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x0c8000", ATTR{remove}="1" + + # Remove NVIDIA Audio devices, if present + ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x040300", ATTR{remove}="1" + + # Enable runtime PM for NVIDIA VGA/3D controller devices on driver bind + ACTION=="bind", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x030000", TEST=="power/control", ATTR{power/control}="auto" + ACTION=="bind", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x030200", TEST=="power/control", ATTR{power/control}="auto" + + # Disable runtime PM for NVIDIA VGA/3D controller devices on driver unbind + ACTION=="unbind", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x030000", TEST=="power/control", ATTR{power/control}="on" + ACTION=="unbind", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x030200", TEST=="power/control", ATTR{power/control}="on" ''; networking = { diff --git a/hosts/common/core/default.nix b/hosts/common/core/default.nix index 036c0d6..0074988 100644 --- a/hosts/common/core/default.nix +++ b/hosts/common/core/default.nix @@ -49,7 +49,6 @@ in pkgs.just pkgs.git pkgs.vim - pkgs.linuxKernel.packages.linux_zen.cpupower ]; system.stateVersion = "24.05"; From ab4c5dc96f6f448d13802596dae55c96be9622d1 Mon Sep 17 00:00:00 2001 From: Sam Date: Sun, 24 Nov 2024 21:10:41 +0000 Subject: [PATCH 2/2] Update NixVim keymaps and TLP battery thresholds - Modify NixVim keymaps for moving selected lines in visual mode - Enable and configure TLP service with updated battery charge thresholds - Adjust CPU scaling governors for both AC and battery power sources --- home/common/core/nixvim/keymaps.nix | 4 ++-- hosts/citadel/default.nix | 20 ++++++++++---------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/home/common/core/nixvim/keymaps.nix b/home/common/core/nixvim/keymaps.nix index f405efa..d0f5654 100644 --- a/home/common/core/nixvim/keymaps.nix +++ b/home/common/core/nixvim/keymaps.nix @@ -100,13 +100,13 @@ programs.nixvim.keymaps = [ # move selected line up or down { mode = ["v"]; - key = "J"; + key = ""; action = ":m '>+1gv=gv"; options = {noremap = true;}; } { mode = ["v"]; - key = "K"; + key = ""; action = ":m '<-2gv=gv"; options = {noremap = true;}; } diff --git a/hosts/citadel/default.nix b/hosts/citadel/default.nix index 6a59938..3be691d 100644 --- a/hosts/citadel/default.nix +++ b/hosts/citadel/default.nix @@ -113,16 +113,16 @@ in { pkgs.lm_sensors ]; - # services.tlp = { - # enable = true; - # settings = { - # CPU_SCALING_GOVERNOR_ON_AC = "ondemand"; - # CPU_SCALING_GOVERNOR_ON_BAT = "powersave"; - # - # START_CHARGE_THRESH_BAT0 = 50; - # STOP_CHARGE_THRESH_BAT0 = 95; - # }; - # }; + services.tlp = { + enable = true; + settings = { + CPU_SCALING_GOVERNOR_ON_AC = "ondemand"; + CPU_SCALING_GOVERNOR_ON_BAT = "powersave"; + + START_CHARGE_THRESH_BAT0 = 60; + STOP_CHARGE_THRESH_BAT0 = 85; + }; + }; hardware = { bluetooth = {