Skip to content

Commit

Permalink
common/gpu/intel: add vaapi configuration options
Browse files Browse the repository at this point in the history
  • Loading branch information
Pandapip1 committed Oct 18, 2024
1 parent 83ebb84 commit a22c02f
Showing 1 changed file with 35 additions and 18 deletions.
53 changes: 35 additions & 18 deletions common/gpu/intel/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
{
Expand Down

0 comments on commit a22c02f

Please sign in to comment.