NixOS Issues with Vulkan after upgrading from 24.05 to 24.11

Hi. I just updated my system from 24.05 to 24.11 using the below commands:

sudo nix-channel --add https://channels.nixos.org/nixos-24.11 nixos
sudo nixos-rebuild switch --upgrade

sudo nix-channel --add https://github.com/nix-community/home-manager/archive/release-24.11.tar.gz home-manager
sudo nix-channel --update
sudo nixos-rebuild switch --upgrade

There was a few warning while I was upgrading like renamings and etc. so I updated my configuration and rebuilt for one more time. I rebooted my system a few times after upgrading. I use Hyprland primarily but same issues happen on GNOME too. I have an NVIDIA GPU and Intel CPU:

unitythemaker@blazingfast ~> nix-shell -p vulkan-tools

[nix-shell:~]$ vkcube --gpu_number 0
Selected GPU 0: Intel(R) UHD Graphics (TGL GT1), type: IntegratedGpu

[nix-shell:~]$ vkcube --gpu_number 1
Selected GPU 1: NVIDIA GeForce RTX 3050 Laptop GPU, type: DiscreteGpu

[nix-shell:~]$ vkcube --gpu_number 2
Selected GPU 2: llvmpipe (LLVM 18.1.8, 256 bits), type: Cpu

[nix-shell:~]$ vkcube --gpu_number 3
GPU 3 specified is not present, GPU count = 3
Specified GPU number is not present

Now I am facing issues with some applications. I will just provide the output of them:

pavucontrol

pavucontrol output
MESA-INTEL: warning: ../src/intel/vulkan/anv_formats.c:763: FINISHME: support YUV colorspace with DRM format modifiers
MESA-INTEL: warning: ../src/intel/vulkan/anv_formats.c:794: FINISHME: support more multi-planar formats with DRM modifiers
Gdk-Message: 22:09:33.088: Error 71 (Protocol error) dispatching to Wayland display.

zed-editor

zeditor --foreground (zed-editor)
[2024-12-03T22:10:52+03:00 ERROR git] Error { code: -9, klass: 4, message: "reference 'refs/heads/main' not found" }
wp_linux_drm_syncobj_manager_v1#44: error 0: Surface already has a syncobj attached
[2024-12-03T22:10:52+03:00 ERROR zed::reliability] {
  "thread": "main",
  "payload": "called `Result::unwrap()` on an `Err` value: ERROR_SURFACE_LOST_KHR",
  "location_data": {
    "file": "/build/zed-editor-0.163.2-vendor/blade-graphics-0.5.0/src/vulkan/init.rs",
    "line": 930
  },
  "backtrace": [
    "core::panicking::panic_fmt",
    "core::result::unwrap_failed",
    "blade_graphics::hal::init::<impl blade_graphics::hal::Context>::resize",
    "gpui::platform::blade::blade_renderer::BladeRenderer::new",
    "gpui::platform::linux::wayland::window::WaylandWindow::new",
    "<gpui::platform::linux::wayland::client::WaylandClient as gpui::platform::linux::platform::LinuxClient>::open_window",
    "gpui::platform::linux::platform::<impl gpui::platform::Platform for P>::open_window",
    "gpui::window::Window::new",
    "gpui::app::async_context::AsyncAppContext::open_window",
    "workspace::Workspace::new_local::{{closure}}::{{closure}}",
    "async_task::raw::RawTask<F,T,S,M>::run",
    "<gpui::platform::linux::wayland::client::WaylandClient as gpui::platform::linux::platform::LinuxClient>::run",
    "gpui::platform::linux::platform::<impl gpui::platform::Platform for P>::run",
    "gpui::app::App::run",
    "zed::main",
    "std::sys::backtrace::__rust_begin_short_backtrace",
    "std::rt::lang_start::{{closure}}",
    "std::rt::lang_start_internal",
    "main",
    "__libc_start_call_main",
    "__libc_start_main_alias_2",
    "_start"
  ],
  "app_version": "0.163.2",
  "release_channel": "Zed",
  "os_name": "Linux Wayland",
  "os_version": "nixos 24.11",
  "architecture": "x86_64",
  "panicked_on": 1733253052504,
  "system_id": "f0b5ae4c-f098-4350-8796-98c1a774beca",
  "installation_id": "6b0cae92-ad57-42a8-a6a9-4ec65232a595",
  "session_id": "99c802fe-2f30-4732-949c-b12a099da792"
}

Extra notes:

  • uncommenting #environment.sessionVariables.GSK_RENDERER = "opengl"; line makes pavucontrol work but not zed-editor.
  • vkcube works without any issues as you can see above.

I tried playing with some options but here is my /etc/nixos/configuration.nix with more focus on graphics related things:

# Edit this configuration file to define what should be installed on
# your system.  Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running ‘nixos-help’).

{ config, pkgs, lib, ... }:

let
  unstable = import <nixos-unstable> { config = { allowUnfree = true; }; };
  unstable-small = import <nixos-unstable-small> { config = { allowUnfree = true; }; };
in {
  imports =
    [ # Include the results of the hardware scan.
      <home-manager/nixos>
      ./hardware-configuration.nix
      ./zapret.nix
    ];

  specialisation = {
    #on-the-go.configuration = {
    #  system.nixos.tags = [ "on-the-go" ];
    #  hardware.nvidia = {
    #    prime.offload.enable = lib.mkForce true;
    #    prime.offload.enableOffloadCmd = lib.mkForce true;
    #    prime.sync.enable = lib.mkForce false;
    #  };
    #};
  };

  nix.settings.auto-optimise-store = true;
  nix.gc = {
    automatic = true;
    dates = "weekly";
    options = "--delete-older-than 14d";
  };

  nix.settings.experimental-features = [ "nix-command" "flakes" ];

  # Bootloader.
  boot.loader.systemd-boot.enable = true;
  boot.loader.efi.canTouchEfiVariables = true;

  // ...

  # Enable the X11 windowing system.
  services.xserver.enable = true;

  # Enable the GNOME Desktop Environment.
  services.xserver.displayManager.gdm.enable = true;
  services.xserver.desktopManager.gnome.enable = true;

  programs.hyprland = {
    # Install the packages from nixpkgs
    enable = true;
    # Whether to enable XWayland
    xwayland.enable = true;
  };

  // ...

    # Enable OpenGL
  hardware.graphics = {
    enable = true;

    enable32Bit = true;

    extraPackages = with pkgs; [
      vaapiVdpau
      intel-media-driver
      libvdpau-va-gl
      nvidia-vaapi-driver
    ];
  };

  # Load nvidia driver for Xorg and Wayland
  services.xserver.videoDrivers = ["nvidia"];

  hardware.nvidia = {
    # Modesetting is required.
    modesetting.enable = true;

    # Nvidia power management. Experimental, and can cause sleep/suspend to fail.
    # Enable this if you have graphical corruption issues or application crashes after waking
    # up from sleep. This fixes it by saving the entire VRAM memory to /tmp/ instead 
    # of just the bare essentials.
    powerManagement.enable = true;

    # Fine-grained power management. Turns off GPU when not in use.
    # Experimental and only works on modern Nvidia GPUs (Turing or newer).
    powerManagement.finegrained = false;

    # Use the NVidia open source kernel module (not to be confused with the
    # independent third-party "nouveau" open source driver).
    # Support is limited to the Turing and later architectures. Full list of 
    # supported GPUs is at: 
    # https://github.com/NVIDIA/open-gpu-kernel-modules#compatible-gpus 
    # Only available from driver 515.43.04+
    # Currently alpha-quality/buggy, so false is currently the recommended setting.
    open = false;

    # Enable the Nvidia settings menu,
	# accessible via `nvidia-settings`.
    nvidiaSettings = true;

    # Optionally, you may need to select the appropriate driver version for your specific GPU.
    package = config.boot.kernelPackages.nvidiaPackages.stable;

    #prime = {
    #  sync.enable = true;

    #  # Make sure to use the correct Bus ID values for your system!
    #  intelBusId = "PCI:0:2:0";
    #  nvidiaBusId = "PCI:1:0:0";
    #  # amdgpuBusId = "PCI:54:0:0"; For AMD GPU
    #};
  };

  // ...

  # Enable sound with pipewire.
  hardware.pulseaudio.enable = false;
  security.rtkit.enable = true;
  services.pipewire = {
    enable = true;
    alsa.enable = true;
    alsa.support32Bit = true;
    pulse.enable = true;
    # If you want to use JACK applications, uncomment this
    #jack.enable = true;

    # use the example session manager (no others are packaged yet so this is enabled by default,
    # no need to redefine it in your config for now)
    #media-session.enable = true;
  };

  users.users.unitythemaker = {
    isNormalUser = true;
    description = "...";
    extraGroups = [ "networkmanager" "wheel" "docker" "wireshark" "kvm" "adbusers" "dialout" ];
    shell = pkgs.fish;
    packages = with pkgs; [
      // ...
    ];
  };

  home-manager.useUserPackages = true;

  home-manager.users.unitythemaker = { pkgs, ... }: {
    programs.fish.enable = true;
  
    # The state version is required and should stay at the version you
    # originally installed.
    home.stateVersion = "24.05";

    dconf.settings = {
      "org/virt-manager/virt-manager/connections" = {
        autoconnect = ["qemu:///system"];
        uris = ["qemu:///system"];
      };
    };

    gtk = {
      enable = true;
      gtk3.extraConfig = {
        gtk-application-prefer-dark-theme = 1;
      };
      gtk4.extraConfig = {
        gtk-application-prefer-dark-theme = 1;
      };
      font = {
        name = "Ubuntu Nerd Font";
        package = pkgs.ubuntu_font_family;
      };
      theme = {
        name = "adw-gtk3-dark";
	package = pkgs.adw-gtk3;
      };
      iconTheme = {
        name = "Adwaita";
	package = pkgs.adwaita-icon-theme;
      };
      cursorTheme = {
        name = "Bibata Modern Classic";
        package = pkgs.bibata-cursors;
	size = 24;
      };
    };

    qt = {
      enable = true;
      platformTheme.name = "qtct";
    };
  };

  # Allow unfree packages
  nixpkgs.config.allowUnfree = true;

  // ...

  # Environment variables
  # environment.sessionVariables.NIXOS_OZONE_WL = "1";
  environment.sessionVariables.QT_WAYLAND_DISABLE_WINDOWDECORATION = "1";
  environment.sessionVariables.SDL_VIDEO_MINIMIZE_ON_FOCUS_LOSS = "0";
  #environment.sessionVariables.GSK_RENDERER = "opengl";

  // ...

  system.stateVersion = "24.05"; # Did you read the comment?
}

What do you mean by that? Are you mixing different channels/nixpkgs revisions in any way?

That is not supported and will cause issues especially in graphical contexts.

Given that Nvidia is the root of 90% of graphical issues on Linux, this is extremely critical information that you should post at the top of your post.

1 Like

Yes, I have a few packages which I want to keep at the latest version. AFAIK, nix automatically handles this by installing different versions of libraries when needed and I didn’t have any issues till this date. Also, using the non-unstable version also doesn’t work with the same error. I didn’t know this was unsupported but as long as they don’t cause any issues which isn’t caused on stable, I want to keep using it. List of unstable packages that I have are: vscode, zed-editor, discord and warp-terminal.

Oh, I am editing my post to move it up. Thank you.

1 Like

It does indeed for everything but this one impurity that is left: Graphics drivers.

It’s non-trivial to fix this.

With Nvidia, that might work okay though since it’s built to work with such scenarios but I wouldn’t trust it.

This is the important bit to know. Please do try to repro with the env var unset though.

1 Like

Okay.

I’ve removed the unstable variables and also removed the “unstable.” prefixes from the package definitions. I then ran sudo nixos-rebuild switch and rebooted my system, but the issue still persists.

vaapiVdpau package only exists in 24.05. I removed it and rebooted, didn’t fix the issue but I think I will keep it uninstalled.

Currently, I am reading this again to make sure my configuration complies: Accelerated Video Playback - NixOS Wiki

I am adding these as they are related:

vainfo behavior on my system:

unitythemaker@blazingfast ~> nix-shell -p libva-utils

[nix-shell:~]$ vainfo
Trying display: wayland
libva info: VA-API version 1.22.0
libva info: Trying to open /run/opengl-driver/lib/dri/iHD_drv_video.so
libva info: Found init function __vaDriverInit_1_22
libva info: va_openDriver() returns 0
vainfo: VA-API version: 1.22 (libva 2.22.0)
vainfo: Driver version: Intel iHD driver for Intel(R) Gen Graphics - 24.3.4 ()
vainfo: Supported profile and entrypoints
      VAProfileNone                   :	VAEntrypointVideoProc
      VAProfileNone                   :	VAEntrypointStats
      VAProfileMPEG2Simple            :	VAEntrypointVLD
      VAProfileMPEG2Simple            :	VAEntrypointEncSlice
      VAProfileMPEG2Main              :	VAEntrypointVLD
      VAProfileMPEG2Main              :	VAEntrypointEncSlice
      VAProfileH264Main               :	VAEntrypointVLD
      VAProfileH264Main               :	VAEntrypointEncSlice
      VAProfileH264Main               :	VAEntrypointFEI
      VAProfileH264Main               :	VAEntrypointEncSliceLP
      VAProfileH264High               :	VAEntrypointVLD
      VAProfileH264High               :	VAEntrypointEncSlice
      VAProfileH264High               :	VAEntrypointFEI
      VAProfileH264High               :	VAEntrypointEncSliceLP
      VAProfileVC1Simple              :	VAEntrypointVLD
      VAProfileVC1Main                :	VAEntrypointVLD
      VAProfileVC1Advanced            :	VAEntrypointVLD
      VAProfileJPEGBaseline           :	VAEntrypointVLD
      VAProfileJPEGBaseline           :	VAEntrypointEncPicture
      VAProfileH264ConstrainedBaseline:	VAEntrypointVLD
      VAProfileH264ConstrainedBaseline:	VAEntrypointEncSlice
      VAProfileH264ConstrainedBaseline:	VAEntrypointFEI
      VAProfileH264ConstrainedBaseline:	VAEntrypointEncSliceLP
      VAProfileVP8Version0_3          :	VAEntrypointVLD
      VAProfileHEVCMain               :	VAEntrypointVLD
      VAProfileHEVCMain               :	VAEntrypointEncSlice
      VAProfileHEVCMain               :	VAEntrypointFEI
      VAProfileHEVCMain               :	VAEntrypointEncSliceLP
      VAProfileHEVCMain10             :	VAEntrypointVLD
      VAProfileHEVCMain10             :	VAEntrypointEncSlice
      VAProfileHEVCMain10             :	VAEntrypointEncSliceLP
      VAProfileVP9Profile0            :	VAEntrypointVLD
      VAProfileVP9Profile1            :	VAEntrypointVLD
      VAProfileVP9Profile2            :	VAEntrypointVLD
      VAProfileVP9Profile3            :	VAEntrypointVLD
      VAProfileHEVCMain12             :	VAEntrypointVLD
      VAProfileHEVCMain12             :	VAEntrypointEncSlice
      VAProfileHEVCMain422_10         :	VAEntrypointVLD
      VAProfileHEVCMain422_10         :	VAEntrypointEncSlice
      VAProfileHEVCMain422_12         :	VAEntrypointVLD
      VAProfileHEVCMain422_12         :	VAEntrypointEncSlice
      VAProfileHEVCMain444            :	VAEntrypointVLD
      VAProfileHEVCMain444            :	VAEntrypointEncSliceLP
      VAProfileHEVCMain444_10         :	VAEntrypointVLD
      VAProfileHEVCMain444_10         :	VAEntrypointEncSliceLP
      VAProfileHEVCMain444_12         :	VAEntrypointVLD
      VAProfileHEVCSccMain            :	VAEntrypointVLD
      VAProfileHEVCSccMain            :	VAEntrypointEncSliceLP
      VAProfileHEVCSccMain10          :	VAEntrypointVLD
      VAProfileHEVCSccMain10          :	VAEntrypointEncSliceLP
      VAProfileHEVCSccMain444         :	VAEntrypointVLD
      VAProfileHEVCSccMain444         :	VAEntrypointEncSliceLP
      VAProfileAV1Profile0            :	VAEntrypointVLD
      VAProfileHEVCSccMain444_10      :	VAEntrypointVLD
      VAProfileHEVCSccMain444_10      :	VAEntrypointEncSliceLP

[nix-shell:~]$ vainfo --display drm
Trying display: drm
libva info: VA-API version 1.22.0
libva info: Trying to open /run/opengl-driver/lib/dri/nvidia_drv_video.so
libva info: Found init function __vaDriverInit_1_0
libva info: va_openDriver() returns 0
vainfo: VA-API version: 1.22 (libva 2.22.0)
vainfo: Driver version: VA-API NVDEC driver [direct backend]
vainfo: Supported profile and entrypoints
      VAProfileMPEG2Simple            :	VAEntrypointVLD
      VAProfileMPEG2Main              :	VAEntrypointVLD
      VAProfileVC1Simple              :	VAEntrypointVLD
      VAProfileVC1Main                :	VAEntrypointVLD
      VAProfileVC1Advanced            :	VAEntrypointVLD
      VAProfileH264Main               :	VAEntrypointVLD
      VAProfileH264High               :	VAEntrypointVLD
      VAProfileH264ConstrainedBaseline:	VAEntrypointVLD
      VAProfileHEVCMain               :	VAEntrypointVLD
      VAProfileVP8Version0_3          :	VAEntrypointVLD
      VAProfileVP9Profile0            :	VAEntrypointVLD
      VAProfileAV1Profile0            :	VAEntrypointVLD
      VAProfileHEVCMain10             :	VAEntrypointVLD
      VAProfileHEVCMain12             :	VAEntrypointVLD
      VAProfileVP9Profile2            :	VAEntrypointVLD
      VAProfileHEVCMain444            :	VAEntrypointVLD
      VAProfileHEVCMain444_10         :	VAEntrypointVLD
      VAProfileHEVCMain444_12         :	VAEntrypointVLD

[nix-shell:~]$ vainfo --display drm --device /dev/dri/renderD128
Trying display: drm
libva info: VA-API version 1.22.0
libva info: Trying to open /run/opengl-driver/lib/dri/nvidia_drv_video.so
libva info: Found init function __vaDriverInit_1_0
libva info: va_openDriver() returns 0
vainfo: VA-API version: 1.22 (libva 2.22.0)
vainfo: Driver version: VA-API NVDEC driver [direct backend]
vainfo: Supported profile and entrypoints
      VAProfileMPEG2Simple            :	VAEntrypointVLD
      VAProfileMPEG2Main              :	VAEntrypointVLD
      VAProfileVC1Simple              :	VAEntrypointVLD
      VAProfileVC1Main                :	VAEntrypointVLD
      VAProfileVC1Advanced            :	VAEntrypointVLD
      VAProfileH264Main               :	VAEntrypointVLD
      VAProfileH264High               :	VAEntrypointVLD
      VAProfileH264ConstrainedBaseline:	VAEntrypointVLD
      VAProfileHEVCMain               :	VAEntrypointVLD
      VAProfileVP8Version0_3          :	VAEntrypointVLD
      VAProfileVP9Profile0            :	VAEntrypointVLD
      VAProfileAV1Profile0            :	VAEntrypointVLD
      VAProfileHEVCMain10             :	VAEntrypointVLD
      VAProfileHEVCMain12             :	VAEntrypointVLD
      VAProfileVP9Profile2            :	VAEntrypointVLD
      VAProfileHEVCMain444            :	VAEntrypointVLD
      VAProfileHEVCMain444_10         :	VAEntrypointVLD
      VAProfileHEVCMain444_12         :	VAEntrypointVLD

[nix-shell:~]$ vainfo --display drm --device /dev/dri/renderD129
Trying display: drm
libva info: VA-API version 1.22.0
libva info: Trying to open /run/opengl-driver/lib/dri/iHD_drv_video.so
libva info: Found init function __vaDriverInit_1_22
libva info: va_openDriver() returns 0
vainfo: VA-API version: 1.22 (libva 2.22.0)
vainfo: Driver version: Intel iHD driver for Intel(R) Gen Graphics - 24.3.4 ()
vainfo: Supported profile and entrypoints
      VAProfileNone                   :	VAEntrypointVideoProc
      VAProfileNone                   :	VAEntrypointStats
      VAProfileMPEG2Simple            :	VAEntrypointVLD
      VAProfileMPEG2Simple            :	VAEntrypointEncSlice
      VAProfileMPEG2Main              :	VAEntrypointVLD
      VAProfileMPEG2Main              :	VAEntrypointEncSlice
      VAProfileH264Main               :	VAEntrypointVLD
      VAProfileH264Main               :	VAEntrypointEncSlice
      VAProfileH264Main               :	VAEntrypointFEI
      VAProfileH264Main               :	VAEntrypointEncSliceLP
      VAProfileH264High               :	VAEntrypointVLD
      VAProfileH264High               :	VAEntrypointEncSlice
      VAProfileH264High               :	VAEntrypointFEI
      VAProfileH264High               :	VAEntrypointEncSliceLP
      VAProfileVC1Simple              :	VAEntrypointVLD
      VAProfileVC1Main                :	VAEntrypointVLD
      VAProfileVC1Advanced            :	VAEntrypointVLD
      VAProfileJPEGBaseline           :	VAEntrypointVLD
      VAProfileJPEGBaseline           :	VAEntrypointEncPicture
      VAProfileH264ConstrainedBaseline:	VAEntrypointVLD
      VAProfileH264ConstrainedBaseline:	VAEntrypointEncSlice
      VAProfileH264ConstrainedBaseline:	VAEntrypointFEI
      VAProfileH264ConstrainedBaseline:	VAEntrypointEncSliceLP
      VAProfileVP8Version0_3          :	VAEntrypointVLD
      VAProfileHEVCMain               :	VAEntrypointVLD
      VAProfileHEVCMain               :	VAEntrypointEncSlice
      VAProfileHEVCMain               :	VAEntrypointFEI
      VAProfileHEVCMain               :	VAEntrypointEncSliceLP
      VAProfileHEVCMain10             :	VAEntrypointVLD
      VAProfileHEVCMain10             :	VAEntrypointEncSlice
      VAProfileHEVCMain10             :	VAEntrypointEncSliceLP
      VAProfileVP9Profile0            :	VAEntrypointVLD
      VAProfileVP9Profile1            :	VAEntrypointVLD
      VAProfileVP9Profile2            :	VAEntrypointVLD
      VAProfileVP9Profile3            :	VAEntrypointVLD
      VAProfileHEVCMain12             :	VAEntrypointVLD
      VAProfileHEVCMain12             :	VAEntrypointEncSlice
      VAProfileHEVCMain422_10         :	VAEntrypointVLD
      VAProfileHEVCMain422_10         :	VAEntrypointEncSlice
      VAProfileHEVCMain422_12         :	VAEntrypointVLD
      VAProfileHEVCMain422_12         :	VAEntrypointEncSlice
      VAProfileHEVCMain444            :	VAEntrypointVLD
      VAProfileHEVCMain444            :	VAEntrypointEncSliceLP
      VAProfileHEVCMain444_10         :	VAEntrypointVLD
      VAProfileHEVCMain444_10         :	VAEntrypointEncSliceLP
      VAProfileHEVCMain444_12         :	VAEntrypointVLD
      VAProfileHEVCSccMain            :	VAEntrypointVLD
      VAProfileHEVCSccMain            :	VAEntrypointEncSliceLP
      VAProfileHEVCSccMain10          :	VAEntrypointVLD
      VAProfileHEVCSccMain10          :	VAEntrypointEncSliceLP
      VAProfileHEVCSccMain444         :	VAEntrypointVLD
      VAProfileHEVCSccMain444         :	VAEntrypointEncSliceLP
      VAProfileAV1Profile0            :	VAEntrypointVLD
      VAProfileHEVCSccMain444_10      :	VAEntrypointVLD
      VAProfileHEVCSccMain444_10      :	VAEntrypointEncSliceLP

Okay, I’ve finally fixed the problem.

The key thing here is VK_ICD_FILENAMES=/run/opengl-driver/share/vulkan/icd.d/nvidia_icd.x86_64.json environment variable. Set this in your /etc/nixos/configuration.nix:

  environment.sessionVariables.VK_ICD_FILENAMES = "/run/opengl-driver/share/vulkan/icd.d/nvidia_icd.x86_64.json";

Both of the below commands worked without any problems:

VK_ICD_FILENAMES=/run/opengl-driver/share/vulkan/icd.d/nvidia_icd.x86_64.json pavucontrol
VK_ICD_FILENAMES=/run/opengl-driver/share/vulkan/icd.d/nvidia_icd.x86_64.json zeditor --foreground

I think there were some errors with my OpenGL or hardware.graphics settings too, so the final version is this:

  hardware.graphics = {                                                                            
    enable = true;                                                                                 
                                                                                                   
    enable32Bit = true;                                                                            
                                                                                                   
    extraPackages = with pkgs; [                                                                   
      nvidia-vaapi-driver                                                                          
      #intel-media-driver                                                                          
      #intel-vaapi-driver                                                                          
      libvdpau-va-gl                                                                               
    ];                                                                                             
                                                                                                   
    extraPackages32 = with pkgs.pkgsi686Linux; [                                                   
      #intel-vaapi-driver                                                                          
    ];                                                                                             
  };

I’ve also enabled Prime back just in case:

  hardware.nvidia = {
    # Modesetting is required.
    modesetting.enable = true;

    # Nvidia power management. Experimental, and can cause sleep/suspend to fail.
    # Enable this if you have graphical corruption issues or application crashes after waking
    # up from sleep. This fixes it by saving the entire VRAM memory to /tmp/ instead 
    # of just the bare essentials.
    powerManagement.enable = true;

    # Fine-grained power management. Turns off GPU when not in use.
    # Experimental and only works on modern Nvidia GPUs (Turing or newer).
    powerManagement.finegrained = false;

    # Use the NVidia open source kernel module (not to be confused with the
    # independent third-party "nouveau" open source driver).
    # Support is limited to the Turing and later architectures. Full list of 
    # supported GPUs is at: 
    # https://github.com/NVIDIA/open-gpu-kernel-modules#compatible-gpus 
    # Only available from driver 515.43.04+
    # Currently alpha-quality/buggy, so false is currently the recommended setting.
    open = false;

    # Enable the Nvidia settings menu,
	# accessible via `nvidia-settings`.
    nvidiaSettings = true;

    # Optionally, you may need to select the appropriate driver version for your specific GPU.
    package = config.boot.kernelPackages.nvidiaPackages.stable;

    prime = {
      sync.enable = true;

      # Make sure to use the correct Bus ID values for your system!
      intelBusId = "PCI:0:2:0";
      nvidiaBusId = "PCI:1:0:0";
      # amdgpuBusId = "PCI:54:0:0"; For AMD GPU
    };
  };
2 Likes