2024-02-04 15:37:31 +01:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
let
|
|
|
|
cfg = config.my.hardware.graphics;
|
|
|
|
in
|
|
|
|
{
|
|
|
|
options.my.hardware.graphics = with lib; {
|
|
|
|
enable = mkEnableOption "graphics configuration";
|
|
|
|
|
|
|
|
gpuFlavor = mkOption {
|
|
|
|
type = with types; nullOr (enum [ "amd" "intel" ]);
|
|
|
|
default = null;
|
|
|
|
example = "intel";
|
|
|
|
description = "Which kind of GPU to install driver for";
|
|
|
|
};
|
|
|
|
|
|
|
|
amd = {
|
|
|
|
enableKernelModule = lib.my.mkDisableOption "Kernel driver module";
|
|
|
|
|
|
|
|
amdvlk = lib.mkEnableOption "Use AMDVLK instead of Mesa RADV driver";
|
|
|
|
};
|
|
|
|
|
|
|
|
intel = {
|
|
|
|
enableKernelModule = lib.my.mkDisableOption "Kernel driver module";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = lib.mkIf cfg.enable (lib.mkMerge [
|
|
|
|
{
|
2024-06-28 19:10:26 +02:00
|
|
|
hardware.graphics = {
|
2024-02-04 15:37:31 +01:00
|
|
|
enable = true;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
# AMD GPU
|
|
|
|
(lib.mkIf (cfg.gpuFlavor == "amd") {
|
|
|
|
boot.initrd.kernelModules = lib.mkIf cfg.amd.enableKernelModule [ "amdgpu" ];
|
|
|
|
|
2024-06-13 13:17:22 +02:00
|
|
|
hardware.amdgpu = {
|
|
|
|
# Vulkan
|
|
|
|
amdvlk = lib.mkIf cfg.amd.amdvlk {
|
|
|
|
enable = true;
|
|
|
|
support32Bit = {
|
|
|
|
enable = true;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2024-06-28 19:10:26 +02:00
|
|
|
hardware.graphics = {
|
2024-02-04 15:37:31 +01:00
|
|
|
extraPackages = with pkgs; [
|
|
|
|
# OpenCL
|
|
|
|
rocmPackages.clr
|
|
|
|
rocmPackages.clr.icd
|
2024-06-13 13:17:22 +02:00
|
|
|
];
|
2024-02-04 15:37:31 +01:00
|
|
|
};
|
|
|
|
})
|
|
|
|
|
|
|
|
# Intel GPU
|
|
|
|
(lib.mkIf (cfg.gpuFlavor == "intel") {
|
|
|
|
boot.initrd.kernelModules = lib.mkIf cfg.intel.enableKernelModule [ "i915" ];
|
|
|
|
|
|
|
|
environment.variables = {
|
|
|
|
VDPAU_DRIVER = "va_gl";
|
|
|
|
};
|
|
|
|
|
2024-06-28 19:10:26 +02:00
|
|
|
hardware.graphics = {
|
2024-02-04 15:37:31 +01:00
|
|
|
extraPackages = with pkgs; [
|
|
|
|
# Open CL
|
|
|
|
intel-compute-runtime
|
|
|
|
|
|
|
|
# VA API
|
|
|
|
intel-media-driver
|
|
|
|
intel-vaapi-driver
|
|
|
|
libvdpau-va-gl
|
|
|
|
];
|
2024-06-13 14:15:41 +02:00
|
|
|
|
|
|
|
extraPackages32 = with pkgs.driversi686Linux; [
|
|
|
|
# VA API
|
|
|
|
intel-media-driver
|
|
|
|
intel-vaapi-driver
|
|
|
|
libvdpau-va-gl
|
|
|
|
];
|
2024-02-04 15:37:31 +01:00
|
|
|
};
|
|
|
|
})
|
|
|
|
]);
|
|
|
|
}
|