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 services.xserver.drivers = singleton
24 { name = "amdgpu"; modules = [ package ]; display = true; };
25
26 hardware.opengl.package = package;
27 hardware.opengl.package32 = package32;
28 hardware.opengl.setLdLibraryPath = true;
29
30 boot.extraModulePackages = [ package.kmod ];
31
32 boot.kernelPackages = pkgs.linuxKernel.packagesFor
33 (pkgs.linuxKernel.kernels.linux_5_10.override {
34 structuredExtraConfig = {
35 DEVICE_PRIVATE = kernel.yes;
36 KALLSYMS_ALL = kernel.yes;
37 };
38 });
39
40 hardware.firmware = [ package.fw ];
41
42 system.activationScripts.setup-amdgpu-pro = ''
43 ln -sfn ${package}/opt/amdgpu{,-pro} /run
44 '';
45
46 system.requiredKernelConfig = with config.lib.kernelConfig; [
47 (isYes "DEVICE_PRIVATE")
48 (isYes "KALLSYMS_ALL")
49 ];
50
51 boot.initrd.extraUdevRulesCommands = mkIf (!config.boot.initrd.systemd.enable) ''
52 cp -v ${package}/etc/udev/rules.d/*.rules $out/
53 '';
54 boot.initrd.services.udev.packages = [ package ];
55
56 environment.systemPackages =
57 [ package.vulkan ] ++
58 # this isn't really DRI, but we'll reuse this option for now
59 optional config.hardware.opengl.driSupport32Bit package32.vulkan;
60
61 environment.etc = {
62 "modprobe.d/blacklist-radeon.conf".source = package + "/etc/modprobe.d/blacklist-radeon.conf";
63 amd.source = package + "/etc/amd";
64 };
65
66 };
67
68}