2023-02-27 13:59:06 +01:00
|
|
|
{
|
2024-05-20 04:06:05 +02:00
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
pkgs,
|
|
|
|
...
|
|
|
|
}:
|
|
|
|
{
|
2024-06-21 23:26:44 +02:00
|
|
|
imports = [ ../24.05-compat.nix ];
|
2023-02-27 13:59:06 +01:00
|
|
|
|
2024-10-18 21:38:51 +02:00
|
|
|
options.hardware.intelgpu = {
|
|
|
|
driver = lib.mkOption {
|
|
|
|
description = "Intel GPU driver to use";
|
|
|
|
type = lib.types.enum [
|
|
|
|
"i915"
|
|
|
|
"xe"
|
|
|
|
];
|
|
|
|
default = "i915";
|
2024-05-20 04:06:05 +02:00
|
|
|
};
|
|
|
|
|
2024-10-18 21:38:51 +02:00
|
|
|
loadInInitrd =
|
|
|
|
lib.mkEnableOption "Load the Intel GPU kernel module at stage 1 boot. (Added to `boot.initrd.kernelModules`)"
|
|
|
|
// {
|
|
|
|
default = true;
|
|
|
|
};
|
2024-10-18 23:16:04 +02:00
|
|
|
|
|
|
|
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";
|
2024-10-18 21:38:51 +02:00
|
|
|
};
|
2024-04-07 21:28:11 +02:00
|
|
|
|
2024-10-18 21:38:51 +02:00
|
|
|
config =
|
|
|
|
let
|
|
|
|
cfg = config.hardware.intelgpu;
|
2024-10-18 23:16:04 +02:00
|
|
|
|
|
|
|
useIntelVaapiDriver = cfg.vaapiDriver == "intel-vaapi-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;
|
|
|
|
};
|
|
|
|
|
2024-10-24 00:16:32 +02:00
|
|
|
# useIntelOcl = useIntelVaapiDriver && (config.hardware.enableAllFirmware or config.nixpkgs.config.allowUnfree or false);
|
|
|
|
useIntelOcl = false; # web.archive.org currently isn't serving the source; for the time being, we'll disable this
|
2024-10-18 23:16:04 +02:00
|
|
|
intel-ocl = pkgs.intel-ocl;
|
|
|
|
|
|
|
|
useIntelMediaDriver = cfg.vaapiDriver == "intel-media-driver" || cfg.vaapiDriver == null;
|
|
|
|
intel-media-driver = pkgs.intel-media-driver;
|
|
|
|
intel-media-driver-32 = pkgs.driversi686Linux.intel-media-driver;
|
|
|
|
intel-compute-runtime = pkgs.intel-compute-runtime;
|
|
|
|
vpl-gpu-rt = pkgs.vpl-gpu-rt or pkgs.onevpl-intel-gpu;
|
2024-10-18 21:38:51 +02:00
|
|
|
in
|
|
|
|
{
|
|
|
|
boot.initrd.kernelModules = lib.optionals cfg.loadInInitrd [ cfg.driver ];
|
2024-05-20 04:06:05 +02:00
|
|
|
|
2024-10-18 23:16:04 +02:00
|
|
|
hardware.graphics.extraPackages =
|
|
|
|
lib.optionals useIntelVaapiDriver [ intel-vaapi-driver ]
|
|
|
|
++ lib.optionals useIntelOcl [ intel-ocl ]
|
|
|
|
++ lib.optionals useIntelMediaDriver [
|
|
|
|
intel-media-driver
|
|
|
|
intel-compute-runtime
|
|
|
|
vpl-gpu-rt
|
|
|
|
];
|
2024-05-20 04:06:05 +02:00
|
|
|
|
2024-10-18 23:16:04 +02:00
|
|
|
hardware.graphics.extraPackages32 =
|
|
|
|
lib.optionals useIntelVaapiDriver [ intel-vaapi-driver-32 ]
|
|
|
|
++ lib.optionals useIntelMediaDriver [ intel-media-driver-32 ];
|
2024-10-18 21:38:51 +02:00
|
|
|
|
|
|
|
assertions = [
|
|
|
|
{
|
|
|
|
assertion = (
|
|
|
|
cfg.driver != "xe" || lib.versionAtLeast config.boot.kernelPackages.kernel.version "6.8"
|
|
|
|
);
|
|
|
|
message = "Intel Xe GPU driver is not supported on kernels earlier than 6.8. Update or use the i915 driver.";
|
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|
2023-02-27 13:59:06 +01:00
|
|
|
}
|