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 systemd.tmpfiles.settings.amdgpu-pro = {
43 "/run/amdgpu"."L+".argument = "${package}/opt/amdgpu";
44 "/run/amdgpu-pro"."L+".argument = "${package}/opt/amdgpu-pro";
45 };
46
47 system.requiredKernelConfig = with config.lib.kernelConfig; [
48 (isYes "DEVICE_PRIVATE")
49 (isYes "KALLSYMS_ALL")
50 ];
51
52 boot.initrd.extraUdevRulesCommands = mkIf (!config.boot.initrd.systemd.enable) ''
53 cp -v ${package}/etc/udev/rules.d/*.rules $out/
54 '';
55 boot.initrd.services.udev.packages = [ package ];
56
57 environment.systemPackages =
58 [ package.vulkan ] ++
59 # this isn't really DRI, but we'll reuse this option for now
60 optional config.hardware.opengl.driSupport32Bit package32.vulkan;
61
62 environment.etc = {
63 "modprobe.d/blacklist-radeon.conf".source = package + "/etc/modprobe.d/blacklist-radeon.conf";
64 amd.source = package + "/etc/amd";
65 };
66
67 };
68
69}