summary refs log tree commit diff
path: root/nixos/modules/hardware/video/amdgpu-pro.nix
blob: d784befc9b8876e7b5fc1836575543b47bbbafaf (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
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";
    };

  };

}