From 4fc9ee5d66a851d043502eb4d8b36ce7f2e63f3d Mon Sep 17 00:00:00 2001 From: Alexander Kobjolke Date: Wed, 25 Feb 2026 21:44:51 +0100 Subject: [PATCH] dregil: Fix suspend/hibernate issue related to nvidia settings --- hosts/dregil/configuration.nix | 10 ------- hosts/dregil/hardware-configuration.nix | 35 ++++++++++++++----------- modules/wm/nvidia.nix | 25 ++++++++++++++++++ modules/wm/x.nix | 1 + 4 files changed, 45 insertions(+), 26 deletions(-) create mode 100644 modules/wm/nvidia.nix diff --git a/hosts/dregil/configuration.nix b/hosts/dregil/configuration.nix index a9c27d7..5c927b2 100644 --- a/hosts/dregil/configuration.nix +++ b/hosts/dregil/configuration.nix @@ -9,15 +9,6 @@ lib, ... }: -let - nvidia-offload = pkgs.writeShellScriptBin "nvidia-offload" '' - export __NV_PRIME_RENDER_OFFLOAD=1 - export __NV_PRIME_RENDER_OFFLOAD_PROVIDER=NVIDIA-G0 - export __GLX_VENDOR_LIBRARY_NAME=nvidia - export __VK_LAYER_NV_optimus=NVIDIA_only - exec "$@" - ''; -in { imports = [ # Include the results of the hardware scan. @@ -90,7 +81,6 @@ in wget ripgrep git - nvidia-offload pinentry-qt ]; diff --git a/hosts/dregil/hardware-configuration.nix b/hosts/dregil/hardware-configuration.nix index 6f9e45d..19426b9 100644 --- a/hosts/dregil/hardware-configuration.nix +++ b/hosts/dregil/hardware-configuration.nix @@ -10,7 +10,10 @@ }: { - imports = [ (modulesPath + "/installer/scan/not-detected.nix") ]; + imports = [ + (modulesPath + "/installer/scan/not-detected.nix") + ../../modules/wm/nvidia.nix + ]; boot.initrd.availableKernelModules = [ "xhci_pci" @@ -92,22 +95,22 @@ powerManagement.cpuFreqGovernor = lib.mkDefault "powersave"; hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; - hardware.nvidia = { - nvidiaSettings = true; - nvidiaPersistenced = true; - open = true; + # hardware.nvidia = { + # nvidiaSettings = true; + # nvidiaPersistenced = true; + # open = true; - # modesetting.enable = true; - package = config.boot.kernelPackages.nvidiaPackages.beta; - # prime = { - # offload.enable = true; - # - # intelBusId = "PCI:1:0:0"; - # nvidiaBusId = "PCI:1:0:0"; - # intelBusId = "0@0:2:0"; - # nvidiaBusId = "1@1:0:0"; - # }; - }; + # # modesetting.enable = true; + # # package = config.boot.kernelPackages.nvidiaPackages.beta; + # # prime = { + # # offload.enable = true; + # # + # # intelBusId = "PCI:1:0:0"; + # # nvidiaBusId = "PCI:1:0:0"; + # # intelBusId = "0@0:2:0"; + # # nvidiaBusId = "1@1:0:0"; + # # }; + # }; hardware.graphics = { enable = true; diff --git a/modules/wm/nvidia.nix b/modules/wm/nvidia.nix new file mode 100644 index 0000000..6bedb23 --- /dev/null +++ b/modules/wm/nvidia.nix @@ -0,0 +1,25 @@ +{ + config, + ... +}: + +{ + hardware.graphics.enable = true; + + services.xserver.videoDrivers = [ "nvidia" ]; + + hardware.nvidia = { + modesetting.enable = true; + nvidiaPersistenced = true; + powerManagement.enable = true; + powerManagement.finegrained = false; + open = false; + nvidiaSettings = true; + package = config.boot.kernelPackages.nvidiaPackages.latest; + }; + + boot.kernelParams = [ + "nvidia-drm.fbdev=1" + "nvidia-drm.modeset=1" + ]; +} diff --git a/modules/wm/x.nix b/modules/wm/x.nix index 8b68d3c..bfcfb03 100644 --- a/modules/wm/x.nix +++ b/modules/wm/x.nix @@ -6,6 +6,7 @@ }: { + imports = [ ./nvidia.nix ]; # Enable the X11 windowing system. services = { dbus = {