92 lines
2.5 KiB
Nix
92 lines
2.5 KiB
Nix
{
|
|
pkgs,
|
|
config,
|
|
lib,
|
|
...
|
|
}: let
|
|
cfg = config.system.graphics;
|
|
in {
|
|
options.system.graphics = {
|
|
enable = lib.mkEnableOption "enables nvidia";
|
|
vendor = lib.mkOption {
|
|
type = lib.types.enum ["intel" "amd" "nvidia"];
|
|
default = "intel";
|
|
description = ''
|
|
set the vendor of your graphics device
|
|
supported options are "intel" "amd" "nvidia"
|
|
'';
|
|
};
|
|
};
|
|
|
|
config = lib.mkIf cfg.enable (lib.mkMerge [
|
|
{
|
|
hardware.graphics.enable = true;
|
|
hardware.graphics.enable32Bit = true;
|
|
}
|
|
|
|
(lib.mkIf (cfg.vendor == "intel") {
|
|
services.xserver.videoDrivers = ["modesetting"];
|
|
|
|
# userspace tools
|
|
environment.systemPackages = with pkgs; [
|
|
intel-gpu-tools
|
|
];
|
|
|
|
hardware.graphics.extraPackages = with pkgs; [
|
|
# Required for modern Intel GPUs (Xe iGPU and ARC)
|
|
intel-media-driver # VA-API (iHD) userspace
|
|
vpl-gpu-rt # oneVPL (QSV) runtime
|
|
|
|
# Optional (compute / tooling):
|
|
intel-compute-runtime # OpenCL (NEO) + Level Zero for Arc/Xe
|
|
];
|
|
|
|
environment.sessionVariables = {
|
|
LIBVA_DRIVER_NAME = "iHD"; # Prefer the modern iHD backend
|
|
};
|
|
})
|
|
|
|
(lib.mkIf (cfg.vendor == "amd") {
|
|
boot.initrd.kernelModules = ["amdgpu"];
|
|
services.xserver.videoDrivers = ["amdgpu"];
|
|
|
|
# userspace tools
|
|
environment.systemPackages = with pkgs; [
|
|
radeontop
|
|
];
|
|
|
|
# enable amd vulkan (program will choose this or regular)
|
|
hardware.graphics.extraPackages = with pkgs; [
|
|
amdvlk
|
|
rocmPackages.clr.icd # enable open cl (compute framework like cuda)
|
|
];
|
|
# ^ but 32 bit
|
|
hardware.graphics.extraPackages32 = with pkgs; [
|
|
driversi686Linux.amdvlk
|
|
];
|
|
|
|
# make hip work (extension on cli.icd ^)
|
|
systemd.tmpfiles.rules = [
|
|
"L+ /opt/rocm/hip - - - - ${pkgs.rocmPackages.clr}"
|
|
];
|
|
})
|
|
|
|
(lib.mkIf (cfg.vendor == "nvidia") {
|
|
boot.kernelModules = ["nvidia" "nvidia_modeset" "nvidia_uvm" "nvidia_drm"];
|
|
services.xserver.videoDrivers = ["nvidia"];
|
|
|
|
# enable nvidia proprietary driver
|
|
hardware.nvidia = {
|
|
modesetting.enable = true; # required
|
|
open = false; # use proprietary driver
|
|
nvidiaSettings = true; # no shit
|
|
powerManagement.enable = false; # can cause sleep issues
|
|
package = config.boot.kernelPackages.nvidiaPackages.stable;
|
|
};
|
|
|
|
# enable docker gpu passthrough
|
|
hardware.nvidia-container-toolkit.enable = true;
|
|
})
|
|
]);
|
|
}
|