From a22c02fcf14cee5c3f82fc2d20052d112c85abf2 Mon Sep 17 00:00:00 2001 From: Gavin John Date: Fri, 18 Oct 2024 14:16:04 -0700 Subject: [PATCH] common/gpu/intel: add vaapi configuration options --- common/gpu/intel/default.nix | 53 ++++++++++++++++++++++++------------ 1 file changed, 35 insertions(+), 18 deletions(-) diff --git a/common/gpu/intel/default.nix b/common/gpu/intel/default.nix index 3a5c8d5ca..54a935737 100644 --- a/common/gpu/intel/default.nix +++ b/common/gpu/intel/default.nix @@ -22,34 +22,51 @@ // { default = true; }; + + vaapiDriver = lib.mkOption { + description = "Intel VAAPI driver to use (use null to use both)"; + type = lib.types.nullOr ( + lib.types.enum [ + "intel-vaapi-driver" + "intel-media-driver" + ] + ); + default = null; # Use both drivers when we don't know which one to use + }; + + enableHybridCodec = lib.mkEnableOption "hybrid codec support for Intel GPUs"; }; config = let cfg = config.hardware.intelgpu; + + useIntelVaapiDriver = cfg.vaapiDriver == "intel-vaapi-driver" || cfg.vaapiDriver == null; + useIntelMediaDriver = cfg.vaapiDriver == "intel-media-driver" || cfg.vaapiDriver == null; + + intel-vaapi-driver = (pkgs.intel-vaapi-driver or pkgs.vaapiIntel).override { + enableHybridCodec = cfg.enableHybridCodec; + }; + intel-vaapi-driver-32 = (pkgs.driversi686Linux.intel-vaapi-driver or pkgs.driversi686Linux.vaapiIntel).override { + enableHybridCodec = cfg.enableHybridCodec; + }; + intel-media-driver = pkgs.intel-media-driver; + intel-media-driver-32 = pkgs.driversi686Linux.intel-media-driver; + vpl-gpu-rt = pkgs.vpl-gpu-rt or pkgs.onevpl-intel-gpu; in { boot.initrd.kernelModules = lib.optionals cfg.loadInInitrd [ cfg.driver ]; - hardware.graphics.extraPackages = with pkgs; [ - ( - if (lib.versionOlder (lib.versions.majorMinor lib.version) "23.11") then - vaapiIntel - else - intel-vaapi-driver.override { enableHybridCodec = true; } - ) - intel-media-driver - ]; + hardware.graphics.extraPackages = + lib.optionals useIntelVaapiDriver [ intel-vaapi-driver ] + ++ lib.optionals useIntelMediaDriver [ + intel-media-driver + vpl-gpu-rt + ]; - hardware.graphics.extraPackages32 = with pkgs.driversi686Linux; [ - ( - if (lib.versionOlder (lib.versions.majorMinor lib.version) "23.11") then - vaapiIntel - else - intel-vaapi-driver.override { enableHybridCodec = true; } - ) - intel-media-driver - ]; + hardware.graphics.extraPackages32 = + lib.optionals useIntelVaapiDriver [ intel-vaapi-driver-32 ] + ++ lib.optionals useIntelMediaDriver [ intel-media-driver-32 ]; assertions = [ {