nixpkgs-suyu/nixos/modules/hardware/video/amdgpu-pro.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

72 lines
1.8 KiB
Nix
Raw Normal View History

2016-09-22 03:42:16 +02:00
# This module provides the proprietary AMDGPU-PRO drivers.
{ config, lib, pkgs, ... }:
2016-09-22 03:42:16 +02:00
with lib;
let
drivers = config.services.xserver.videoDrivers;
enabled = elem "amdgpu-pro" drivers;
package = config.boot.kernelPackages.amdgpu-pro;
2018-09-17 03:12:59 +02:00
package32 = pkgs.pkgsi686Linux.linuxPackages.amdgpu-pro.override { kernel = null; };
2016-09-22 03:42:16 +02:00
opengl = config.hardware.opengl;
in
{
config = mkIf enabled {
2018-09-17 03:12:59 +02:00
nixpkgs.config.xorg.abiCompat = "1.20";
2016-09-22 03:42:16 +02:00
services.xserver.drivers = singleton
{ name = "amdgpu"; modules = [ package ]; display = true; };
2016-09-22 03:42:16 +02:00
hardware.opengl.package = package;
hardware.opengl.package32 = package32;
nixos: Don't set LD_LIBRARY_PATH for graphics drivers that don't need it. A new internal option `hardware.opengl.setLdLibraryPath` is added which controls if `LD_LIBRARY_PATH` should be set to `/run/opengl-driver(-32)/lib`. It is false by default and is meant to be set to true by any driver which requires it. If this option is false, then `opengl.nix` and `xserver.nix` will not set `LD_LIBRARY_PATH`. Currently Mesa and NVidia drivers don't set `setLdLibraryPath` because they work with libglvnd and do not override libraries, while `amdgpu-pro`, `ati` and `parallels-guest` set it to true (the former two really need it, the last one doesn't build so is presumed to). Additionally, the `libPath` attribute within entries of `services.xserver.drivers` is removed. This made `xserver.nix` add the driver path directly to the `LD_LIBRARY_PATH` for the display manager (including X server). Not only is it redundant when the driver is added to `hardware.opengl.package` (assuming that `hardware.opengl.enable` is true), in fact all current drivers except `ati` set it incorrectly to the package path instead of package/lib. This removal of `LD_LIBRARY_PATH` could break certain packages using CUDA, but only those that themselves load `libcuda` or other NVidia driver libraries using `dlopen` (not if they just use `cudatoolkit`). A few have already been fixed but it is practically impossible to test all because most packages using CUDA are libraries/frameworks without a simple way to test. Fixes #11434 if only Mesa or NVidia graphics drivers are used.
2019-05-24 01:21:57 +02:00
hardware.opengl.setLdLibraryPath = true;
2016-09-22 03:42:16 +02:00
2018-09-17 03:12:59 +02:00
boot.extraModulePackages = [ package.kmod ];
2018-01-10 01:49:55 +01:00
2018-09-17 03:12:59 +02:00
boot.kernelPackages = pkgs.linuxKernel.packagesFor
(pkgs.linuxKernel.kernels.linux_5_10.override {
structuredExtraConfig = {
DEVICE_PRIVATE = kernel.yes;
KALLSYMS_ALL = kernel.yes;
};
});
2016-09-22 03:42:16 +02:00
2018-09-17 03:12:59 +02:00
hardware.firmware = [ package.fw ];
2016-09-22 03:42:16 +02:00
system.activationScripts.setup-amdgpu-pro = ''
2018-09-17 03:12:59 +02:00
ln -sfn ${package}/opt/amdgpu{,-pro} /run
2016-09-22 03:42:16 +02:00
'';
2018-01-10 01:49:55 +01:00
system.requiredKernelConfig = with config.lib.kernelConfig; [
2018-09-17 03:12:59 +02:00
(isYes "DEVICE_PRIVATE")
2018-01-10 01:49:55 +01:00
(isYes "KALLSYMS_ALL")
];
boot.initrd.extraUdevRulesCommands = mkIf (!config.boot.initrd.systemd.enable) ''
2018-09-17 03:12:59 +02:00
cp -v ${package}/etc/udev/rules.d/*.rules $out/
'';
boot.initrd.services.udev.packages = [ package ];
2018-09-17 03:12:59 +02:00
environment.systemPackages =
[ package.vulkan ] ++
# this isn't really DRI, but we'll reuse this option for now
optional config.hardware.opengl.driSupport32Bit package32.vulkan;
2016-09-22 03:42:16 +02:00
environment.etc = {
2018-09-17 03:12:59 +02:00
"modprobe.d/blacklist-radeon.conf".source = package + "/etc/modprobe.d/blacklist-radeon.conf";
amd.source = package + "/etc/amd";
2016-09-22 03:42:16 +02:00
};
};
}