From d058b2cf72daf6db304bb954c04444263de655bb Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 12 Nov 2024 16:09:09 +0000 Subject: [PATCH 1/7] Update nixvim keymaps and harpoon plugin - Add indentation and line movement keymaps in visual mode - Add keymap for adding files in harpoon plugin --- home/common/core/nixvim/keymaps.nix | 34 ++++++++++++++++++--- home/common/core/nixvim/plugins/harpoon.nix | 1 + 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/home/common/core/nixvim/keymaps.nix b/home/common/core/nixvim/keymaps.nix index ae02fd7..3e92f0a 100644 --- a/home/common/core/nixvim/keymaps.nix +++ b/home/common/core/nixvim/keymaps.nix @@ -1,13 +1,11 @@ { - programs.nixvim.keymaps = [ +programs.nixvim.keymaps = [ # Switching buffers { mode = ["n"]; action = "h"; key = ""; - options = { - silent = true; - }; + options = {silent = true;}; } { mode = ["n"]; @@ -113,5 +111,33 @@ action = ": resize +1"; options = {noremap = true;}; } + + # indent line in or out + { + mode = ["v"]; + key = "<"; + action = " Date: Tue, 12 Nov 2024 17:03:53 +0000 Subject: [PATCH 2/7] Refactor Telescope keymaps to dedicated telescope plugin file - Remove Telescope keymaps from keymaps.nix - Add Telescope keymaps to telescope.nix - Include new keymap for grep string under cursor and recently opened files --- home/common/core/nixvim/keymaps.nix | 29 ------------ home/common/core/nixvim/plugins/telescope.nix | 44 +++++++++++++++++++ 2 files changed, 44 insertions(+), 29 deletions(-) diff --git a/home/common/core/nixvim/keymaps.nix b/home/common/core/nixvim/keymaps.nix index 3e92f0a..f405efa 100644 --- a/home/common/core/nixvim/keymaps.nix +++ b/home/common/core/nixvim/keymaps.nix @@ -50,35 +50,6 @@ programs.nixvim.keymaps = [ options = {noremap = true;}; } - # Telescope Plugin - { - # find files - mode = ["n"]; - key = "ff"; - action = "Telescope find_files"; - options = {noremap = true;}; - } - { - # live grep - mode = ["n"]; - key = "fg"; - action = "Telescope live_grep"; - options = {noremap = true;}; - } - { - # buffers - mode = ["n"]; - key = "fb"; - action = "Telescope buffers"; - options = {noremap = true;}; - } - { - # help tags - mode = ["n"]; - key = "fh"; - action = "Telescope help_tags"; - options = {noremap = true;}; - } # paste over selected text without yanking it { mode = ["v"]; diff --git a/home/common/core/nixvim/plugins/telescope.nix b/home/common/core/nixvim/plugins/telescope.nix index 9582b09..e309362 100644 --- a/home/common/core/nixvim/plugins/telescope.nix +++ b/home/common/core/nixvim/plugins/telescope.nix @@ -3,4 +3,48 @@ enable = true; extensions.fzy-native.enable = true; }; + keymaps = [ + { + # find files + mode = ["n"]; + key = "ff"; + action = "Telescope find_files"; + options = {noremap = true;}; + } + { + # live grep + mode = ["n"]; + key = "fg"; + action = "Telescope live_grep"; + options = {noremap = true;}; + } + { + # grep string under cursor + mode = ["n"]; + key = "fs"; + action = "Telescope string_grep"; + options = {noremap = true;}; + } + { + # buffers + mode = ["n"]; + key = "fb"; + action = "Telescope buffers"; + options = {noremap = true;}; + } + { + # help tags + mode = ["n"]; + key = "fh"; + action = "Telescope help_tags"; + options = {noremap = true;}; + } + { + # show recently opened files + mode = ["n"]; + key = "fo"; + action = "Telescope oldfiles"; + options = {noremap = true;}; + } + ]; } From cdc75090ff9cb572a659b46b7e0ac9f850e78fb2 Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 12 Nov 2024 18:21:15 +0000 Subject: [PATCH 3/7] Add keymaps and settings for nixvim plugins - Add Conform auto-format document keymap in conform.nix - Enable and configure Oil plugin settings in oil.nix - Update Telescope keymaps definition in telescope.nix --- home/common/core/nixvim/plugins/conform.nix | 12 ++++++++++++ home/common/core/nixvim/plugins/oil.nix | 4 ++++ home/common/core/nixvim/plugins/telescope.nix | 2 +- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/home/common/core/nixvim/plugins/conform.nix b/home/common/core/nixvim/plugins/conform.nix index a2bcc28..5c1bd48 100644 --- a/home/common/core/nixvim/plugins/conform.nix +++ b/home/common/core/nixvim/plugins/conform.nix @@ -38,4 +38,16 @@ } ''; + programs.nixvim.keymaps = [ + # format document with Conform + { + mode = ["n"]; + key = "cf"; + action = "Format"; + options = { + silent = true; + desc = "Conform auto-format document"; + }; + } + ]; } diff --git a/home/common/core/nixvim/plugins/oil.nix b/home/common/core/nixvim/plugins/oil.nix index e10b7d1..07176b8 100644 --- a/home/common/core/nixvim/plugins/oil.nix +++ b/home/common/core/nixvim/plugins/oil.nix @@ -1,5 +1,9 @@ { programs.nixvim.plugins.oil = { enable = true; + settings = { + columns = ["icon"]; + view_options.show_hidden = true; + }; }; } diff --git a/home/common/core/nixvim/plugins/telescope.nix b/home/common/core/nixvim/plugins/telescope.nix index e309362..477e3ad 100644 --- a/home/common/core/nixvim/plugins/telescope.nix +++ b/home/common/core/nixvim/plugins/telescope.nix @@ -3,7 +3,7 @@ enable = true; extensions.fzy-native.enable = true; }; - keymaps = [ + programs.nixvim.keymaps = [ { # find files mode = ["n"]; From d224d55c1ad6d0705f55b3030fa636ecabd5f92b Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 12 Nov 2024 19:41:27 +0000 Subject: [PATCH 4/7] add nvidia and prime to citadel --- hosts/citadel/default.nix | 61 +++++++++++++++++++++++++++++++-------- 1 file changed, 49 insertions(+), 12 deletions(-) diff --git a/hosts/citadel/default.nix b/hosts/citadel/default.nix index 2daabc8..24fc4fd 100644 --- a/hosts/citadel/default.nix +++ b/hosts/citadel/default.nix @@ -71,10 +71,12 @@ in { }; }; - swapDevices = [ { - device = "/.swapvol/swapfile"; - size = 32*1024; - } ]; + swapDevices = [ + { + device = "/.swapvol/swapfile"; + size = 32 * 1024; + } + ]; services = { libinput.touchpad.accelSpeed = "0.5"; @@ -82,14 +84,14 @@ in { xkb.options = "caps:swapescape"; dpi = 196; upscaleDefaultCursor = true; - # FIXME this doesnt work for some reason - # displayManager.sessionCommands = pkgs.writeShellScriptBin "key-remaps" '' - # ${pkgs.xorg.xmodmap}/bin/xmodmap -e "keycode 64 = Mode_switch" - # ${pkgs.xorg.xmodmap}/bin/xmodmap -e "keycode 43 = h H Left H" - # ${pkgs.xorg.xmodmap}/bin/xmodmap -e "keycode 44 = j J Down J" - # ${pkgs.xorg.xmodmap}/bin/xmodmap -e "keycode 45 = k K Up K" - # ${pkgs.xorg.xmodmap}/bin/xmodmap -e "keycode 46 = l L Right L" - # ''; + # FIXME this doesnt work for some reason + # displayManager.sessionCommands = pkgs.writeShellScriptBin "key-remaps" '' + # ${pkgs.xorg.xmodmap}/bin/xmodmap -e "keycode 64 = Mode_switch" + # ${pkgs.xorg.xmodmap}/bin/xmodmap -e "keycode 43 = h H Left H" + # ${pkgs.xorg.xmodmap}/bin/xmodmap -e "keycode 44 = j J Down J" + # ${pkgs.xorg.xmodmap}/bin/xmodmap -e "keycode 45 = k K Up K" + # ${pkgs.xorg.xmodmap}/bin/xmodmap -e "keycode 46 = l L Right L" + # ''; }; }; @@ -123,6 +125,41 @@ in { ]; }; + # nvidia + hardware.opengl = { + enable = true; + }; + + services.xserver.videoDrivers = ["nvidia"]; + + hardware.nvidia = { + prime = { + offload = { + enable = true; + enableOffloadCmd = true; + }; + intelBusId = "PCI:0:2:0"; + nvidiaBusId = "PCI:1:0:0"; + }; + modesetting.enable = true; + powerManagement.enable = false; + powerManagement.finegrained = false; + open = false; + nvidiaSettings = true; + # FIXME issue with stable nvidia driver and latest linux kernel + # use mkDriver to specify newer nvidia driver that is compatible + # see: https://github.com/NixOS/nixpkgs/issues/341844#issuecomment-2351075413 + # and https://discourse.nixos.org/t/builder-for-nvidia-x11-550-78-6-10-drv-failed-with-exit-code-2/49360/32 + package = config.boot.kernelPackages.nvidiaPackages.mkDriver { + version = "555.58.02"; + sha256_64bit = "sha256-xctt4TPRlOJ6r5S54h5W6PT6/3Zy2R4ASNFPu8TSHKM="; + sha256_aarch64 = "sha256-wb20isMrRg8PeQBU96lWJzBMkjfySAUaqt4EgZnhyF8="; + openSha256 = "sha256-8hyRiGB+m2hL3c9MDA/Pon+Xl6E788MZ50WrrAGUVuY="; + settingsSha256 = "sha256-ZpuVZybW6CFN/gz9rx+UJvQ715FZnAOYfHn5jt5Z2C8="; + persistencedSha256 = "sha256-a1D7ZZmcKFWfPjjH1REqPM5j/YLWKnbkP9qfRyIyxAw="; + }; + }; + networking = { hostName = "citadel"; networkmanager.enable = true; From c85215b5b4eebecbc2726ddef8882a413b18ffe6 Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 12 Nov 2024 21:18:21 +0000 Subject: [PATCH 5/7] add throttled to citadel --- hosts/citadel/default.nix | 5 +++++ hosts/common/optional/gaming.nix | 3 --- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/hosts/citadel/default.nix b/hosts/citadel/default.nix index 24fc4fd..60d850d 100644 --- a/hosts/citadel/default.nix +++ b/hosts/citadel/default.nix @@ -54,6 +54,7 @@ in { ../common/optional/backlight.nix ../common/optional/xmodmap-arrow-remaps.nix ../common/optional/nix-ld.nix + ../common/optional/gaming.nix ]; boot = { @@ -95,6 +96,10 @@ in { }; }; + # fix cpu throttling on Lenovo Thinkpad + # see: https://github.com/erpalma/throttled + services.throttled.enable = true; + environment.variables = { GDK_SCALE = "2.2"; GDK_DPI_SCALE = "0.8"; diff --git a/hosts/common/optional/gaming.nix b/hosts/common/optional/gaming.nix index 82adb7c..eb41d0e 100644 --- a/hosts/common/optional/gaming.nix +++ b/hosts/common/optional/gaming.nix @@ -9,7 +9,6 @@ # Steam mangohud gamemode - gamescope # WINE wine @@ -41,11 +40,9 @@ programs.steam = { enable = true; - gamescopeSession.enable = true; }; programs.gamemode.enable = true; - programs.gamescope.enable = true; nixpkgs.config.packageOverrides = pkgs: { steam = pkgs.steam.override { From 592309f30a14a67724d3adf4e738f8687981a82e Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 12 Nov 2024 23:07:22 +0000 Subject: [PATCH 6/7] add kodi for sparky --- home/common/optional/desktop/common/kodi.nix | 13 +++++++++++++ home/sparky.nix | 1 + 2 files changed, 14 insertions(+) create mode 100644 home/common/optional/desktop/common/kodi.nix diff --git a/home/common/optional/desktop/common/kodi.nix b/home/common/optional/desktop/common/kodi.nix new file mode 100644 index 0000000..dcf7fb1 --- /dev/null +++ b/home/common/optional/desktop/common/kodi.nix @@ -0,0 +1,13 @@ +{ + pkgs, + ... +}: { + programs.kodi = { + enable = true; + package = pkgs.kodi.withPackages (kodiPkgs: + with kodiPkgs; [ + netflix + jellycon + ]); + }; +} diff --git a/home/sparky.nix b/home/sparky.nix index 8b938dd..36786d9 100644 --- a/home/sparky.nix +++ b/home/sparky.nix @@ -11,6 +11,7 @@ ./common/optional/git.nix ./common/optional/syncthing.nix ./common/optional/desktop/cinnamon + ./common/optional/desktop/common/kodi.nix ]; From 2ef417b6b14be7ceffd26ad10f2e0f9634e1f28f Mon Sep 17 00:00:00 2001 From: Sam Date: Wed, 13 Nov 2024 12:09:17 +0000 Subject: [PATCH 7/7] Update NVIDIA configuration and add cpupower package - Enable nvidiaPersistenced and add udev rules for NVIDIA devices in citadel/default.nix - Add boot.extraModprobeConfig for NVreg_DynamicPowerManagement and NVreg_EnableGpuFirmware - Include the cpupower package in common/core/default.nix --- hosts/citadel/default.nix | 28 +++++++++++++++++++++++++++- hosts/common/core/default.nix | 1 + 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/hosts/citadel/default.nix b/hosts/citadel/default.nix index 60d850d..5c6a896 100644 --- a/hosts/citadel/default.nix +++ b/hosts/citadel/default.nix @@ -135,7 +135,7 @@ in { enable = true; }; - services.xserver.videoDrivers = ["nvidia"]; + services.xserver.videoDrivers = [ "nvidia" ]; hardware.nvidia = { prime = { @@ -146,6 +146,7 @@ in { intelBusId = "PCI:0:2:0"; nvidiaBusId = "PCI:1:0:0"; }; + nvidiaPersistenced = true; modesetting.enable = true; powerManagement.enable = false; powerManagement.finegrained = false; @@ -164,6 +165,31 @@ in { persistencedSha256 = "sha256-a1D7ZZmcKFWfPjjH1REqPM5j/YLWKnbkP9qfRyIyxAw="; }; }; + # https://bbs.archlinux.org/viewtopic.php?id=297276 for NVreg_EnableGpuFirmware fix + # 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" + ''; networking = { hostName = "citadel"; diff --git a/hosts/common/core/default.nix b/hosts/common/core/default.nix index 0074988..036c0d6 100644 --- a/hosts/common/core/default.nix +++ b/hosts/common/core/default.nix @@ -49,6 +49,7 @@ in pkgs.just pkgs.git pkgs.vim + pkgs.linuxKernel.packages.linux_zen.cpupower ]; system.stateVersion = "24.05";