Black screen after suspend/hibernate with nvidia

That’s superfluous: nixpkgs/nixos/modules/hardware/video/nvidia.nix at 9b5ac7ad45298d58640540d0323ca217f32a6762 · NixOS/nixpkgs · GitHub

As are all the boot.kernelModules (those are the defaults) and boot.kernelParams (since you set hardware.nvidia.modesetting.enable).

I’m suspicious of the other extraModProbeConfig options, too. Most of them look useless. vblank_sem_control=0 might do something, but it will likely cause other issues that are less immediately apparent, and if it does fix anything the original issue will eventually be solved with a driver update, at which point you now have this useless, potentially problematic option set, so at the very least you should add a TODO comment to remove it.

I’d really suggest just removing all those boot options unless you actually know what they do or have asserted that a particular one fixes an issue you’ve run into by isolating all other variables.


In addition:

Nvidia recommend you set this to true, since your GPU supports it.

You’re also duplicating a lot of default options in the hardware.nvidia module, check search.nixos.org to see option defaults; it’s usually best to leave defaults at the default, in case upstream changes them for a reason - then you don’t need to figure out that reason as well.


But yes, the powermanagement daemon is important to make sleep work, I would suspect that missing that setting is what is causing issues for a lot of people here, as pointed out much further up in the thread :wink:

3 Likes

thank your share, your configuration also fixes black screen after suspend/hibernate issue for me😆
my GPU is 3060

1 Like

I had the same problem but even with this configuration I couldn’t see any NVIDIA related services in systemctl. I explicitly enabled these services and now the black screen is gone.

My setup for RTX 2070 super with KDE:

  boot.kernelParams = [
  "nvidia.NVreg_PreserveVideoMemoryAllocations=1"
  ];
  # Enable OpenGL/Graphics driver support
  hardware.graphics = {
    enable = true;
    enable32Bit = true; # Crucial for Steam and MangoHud
  };
  
  # Tell the X server / Wayland to use the NVIDIA driver
  services.xserver.videoDrivers = ["nvidia"];

  # Configure NVIDIA specific settings
  hardware.nvidia = {
    # Modesetting is required for Wayland and compositors (like KDE Plasma 6)
    modesetting.enable = true;

    # Power management is required for experimental features like sleep/suspend.
    # Turn this on if you experience problems waking up from sleep.
    powerManagement.enable = true;
    powerManagement.finegrained = false;

    # Use the NVidia open source kernel module (recommended for Turing and newer GPUs)
    open = true;

    # Enable the Nvidia settings menu (accessible via nvidia-settings CLI/GUI)
    nvidiaSettings = true;

    # Select the appropriate driver version
    package = config.boot.kernelPackages.nvidiaPackages.stable;
  };

  systemd.services = {
    "nvidia-suspend" = {
      wantedBy = [ "sleep.target" ];
      serviceConfig = { Type = "oneshot"; };
      script = "${config.hardware.nvidia.package.bin}/bin/nvidia-suspend";
    };
    "nvidia-resume" = {
      wantedBy = [ "suspend.target" ];
      serviceConfig = { Type = "oneshot"; };
      script = "${config.hardware.nvidia.package.bin}/bin/nvidia-resume";
    };
    "nvidia-hibernate" = {
      wantedBy = [ "hibernate.target" ];
      serviceConfig = { Type = "oneshot"; };
      script = "${config.hardware.nvidia.package.bin}/bin/nvidia-hibernate";
    };
  };