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

69 lines
1.6 KiB
Nix
Raw Normal View History

2016-09-22 02:42:16 +01:00
# This module provides the proprietary AMDGPU-PRO drivers.
{ config, lib, pkgs, ... }:
2016-09-22 02:42:16 +01:00
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 { libsOnly = true; kernel = null; };
2016-09-22 02:42:16 +01:00
opengl = config.hardware.opengl;
2018-01-10 00:49:55 +00:00
kernel = pkgs.linux_4_9.override {
extraConfig = ''
KALLSYMS_ALL y
'';
};
2016-09-22 02:42:16 +01:00
in
{
config = mkIf enabled {
2018-01-10 00:49:55 +00:00
nixpkgs.config.xorg.abiCompat = "1.19";
2016-09-22 02:42:16 +01:00
services.xserver.drivers = singleton
{ name = "amdgpu"; modules = [ package ]; display = true; };
2016-09-22 02:42:16 +01: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 00:21:57 +01:00
hardware.opengl.setLdLibraryPath = true;
2016-09-22 02:42:16 +01:00
boot.extraModulePackages = [ package ];
2018-01-10 00:49:55 +00:00
boot.kernelPackages =
pkgs.recurseIntoAttrs (pkgs.linuxPackagesFor kernel);
2016-09-22 02:42:16 +01:00
boot.blacklistedKernelModules = [ "radeon" ];
hardware.firmware = [ package ];
system.activationScripts.setup-amdgpu-pro = ''
mkdir -p /run/lib
ln -sfn ${package}/lib ${package.libCompatDir}
2018-01-10 00:49:55 +00:00
ln -sfn ${package} /run/amdgpu-pro
2016-09-22 02:42:16 +01:00
'' + optionalString opengl.driSupport32Bit ''
ln -sfn ${package32}/lib ${package32.libCompatDir}
'';
2018-01-10 00:49:55 +00:00
system.requiredKernelConfig = with config.lib.kernelConfig; [
(isYes "KALLSYMS_ALL")
];
2016-09-22 02:42:16 +01:00
environment.etc = {
"amd/amdrc".source = package + "/etc/amd/amdrc";
"amd/amdapfxx.blb".source = package + "/etc/amd/amdapfxx.blb";
"gbm/gbm.conf".source = package + "/etc/gbm/gbm.conf";
};
};
}