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

# for Accelerated Video Playback
# https://wiki.nixos.org/wiki/Accelerated_Video_Playback
{
  hardware.graphics = {
    enable = true;
    enable32Bit = true;  # Recommended for legacy/32-bit support.
    extraPackages = with pkgs; [
      intel-media-driver	# Intel Vulkan/media driver (Gen9+ iGPUs).
      intel-vaapi-driver	# For older processors. LIBVA_DRIVER_NAME=i965, works better for firefox/chromium?
      vpl-gpu-rt		# For Quick Sync Video
      vulkan-loader             # Core Vulkan runtime.
      vulkan-tools              # Diagnostic tools (for example, `vulkaninfo`).
      mesa                      # Open-source Vulkan drivers (RADV for AMD, ANV for Intel).
      amdvlk                    # AMD's official Vulkan driver (alternative to RADV).
    ];
  };

  hardware.graphics.extraPackages32 = with pkgs.pkgsi686Linux; [
    vulkan-loader                        # Vulkan runtime (32-bit).
    driversi686Linux.mesa                # 32-bit Vulkan drivers for AMD/Intel.
    driversi686Linux.intel-media-driver  # Intel 32-bit media driver.
    driversi686Linux.amdvlk              # 32-bit support for AMD's official Vulkan driver.
  ];

  environment.sessionVariables = { LIBVA_DRIVER_NAME = "iHD"; }; # Optionally, set the environment variable
}
