1# This module provides the proprietary AMDGPU-PRO drivers.
2
3{ config, lib, pkgs, ... }:
4
5with lib;
6
7let
8
9 drivers = config.services.xserver.videoDrivers;
10
11 enabled = elem "amdgpu-pro" drivers;
12
13 package = config.boot.kernelPackages.amdgpu-pro;
14 package32 = pkgs.pkgsi686Linux.linuxPackages.amdgpu-pro.override { kernel = null; };
15
16 opengl = config.hardware.opengl;
17
18in
19
20{
21
22 config = mkIf enabled {
23
24 nixpkgs.config.xorg.abiCompat = "1.20";
25
26 services.xserver.drivers = singleton
27 { name = "amdgpu"; modules = [ package ]; display = true; };
28
29 hardware.opengl.package = package;
30 hardware.opengl.package32 = package32;
31 hardware.opengl.setLdLibraryPath = true;
32
33 boot.extraModulePackages = [ package.kmod ];
34
35 boot.kernelPackages = pkgs.linuxKernel.packagesFor
36 (pkgs.linuxKernel.kernels.linux_5_10.override {
37 structuredExtraConfig = {
38 DEVICE_PRIVATE = kernel.yes;
39 KALLSYMS_ALL = kernel.yes;
40 };
41 });
42
43 hardware.firmware = [ package.fw ];
44
45 system.activationScripts.setup-amdgpu-pro = ''
46 ln -sfn ${package}/opt/amdgpu{,-pro} /run
47 '';
48
49 system.requiredKernelConfig = with config.lib.kernelConfig; [
50 (isYes "DEVICE_PRIVATE")
51 (isYes "KALLSYMS_ALL")
52 ];
53
54 boot.initrd.extraUdevRulesCommands = mkIf (!config.boot.initrd.systemd.enable) ''
55 cp -v ${package}/etc/udev/rules.d/*.rules $out/
56 '';
57 boot.initrd.services.udev.packages = [ package ];
58
59 environment.systemPackages =
60 [ package.vulkan ] ++
61 # this isn't really DRI, but we'll reuse this option for now
62 optional config.hardware.opengl.driSupport32Bit package32.vulkan;
63
64 environment.etc = {
65 "modprobe.d/blacklist-radeon.conf".source = package + "/etc/modprobe.d/blacklist-radeon.conf";
66 amd.source = package + "/etc/amd";
67 };
68
69 };
70
71}