diff options
Diffstat (limited to 'nixos/modules/hardware/video/amdgpu-pro.nix')
-rw-r--r-- | nixos/modules/hardware/video/amdgpu-pro.nix | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/nixos/modules/hardware/video/amdgpu-pro.nix b/nixos/modules/hardware/video/amdgpu-pro.nix new file mode 100644 index 00000000000..d784befc9b8 --- /dev/null +++ b/nixos/modules/hardware/video/amdgpu-pro.nix @@ -0,0 +1,70 @@ +# This module provides the proprietary AMDGPU-PRO drivers. + +{ config, lib, pkgs, ... }: + +with lib; + +let + + drivers = config.services.xserver.videoDrivers; + + enabled = elem "amdgpu-pro" drivers; + + package = config.boot.kernelPackages.amdgpu-pro; + package32 = pkgs.pkgsi686Linux.linuxPackages.amdgpu-pro.override { kernel = null; }; + + opengl = config.hardware.opengl; + +in + +{ + + config = mkIf enabled { + + nixpkgs.config.xorg.abiCompat = "1.20"; + + services.xserver.drivers = singleton + { name = "amdgpu"; modules = [ package ]; display = true; }; + + hardware.opengl.package = package; + hardware.opengl.package32 = package32; + hardware.opengl.setLdLibraryPath = true; + + boot.extraModulePackages = [ package.kmod ]; + + boot.kernelPackages = pkgs.linuxKernel.packagesFor + (pkgs.linuxKernel.kernels.linux_5_10.override { + structuredExtraConfig = { + DEVICE_PRIVATE = kernel.yes; + KALLSYMS_ALL = kernel.yes; + }; + }); + + hardware.firmware = [ package.fw ]; + + system.activationScripts.setup-amdgpu-pro = '' + ln -sfn ${package}/opt/amdgpu{,-pro} /run + ''; + + system.requiredKernelConfig = with config.lib.kernelConfig; [ + (isYes "DEVICE_PRIVATE") + (isYes "KALLSYMS_ALL") + ]; + + boot.initrd.extraUdevRulesCommands = '' + cp -v ${package}/etc/udev/rules.d/*.rules $out/ + ''; + + environment.systemPackages = + [ package.vulkan ] ++ + # this isn't really DRI, but we'll reuse this option for now + optional config.hardware.opengl.driSupport32Bit package32.vulkan; + + environment.etc = { + "modprobe.d/blacklist-radeon.conf".source = package + "/etc/modprobe.d/blacklist-radeon.conf"; + amd.source = package + "/etc/amd"; + }; + + }; + +} |