2024-07-26 23:07:07 +00:00
|
|
|
# WARNING: This file is currently untested
|
2024-05-15 18:29:28 +00:00
|
|
|
# (I didn't yet run this NixOS config on any AMD GPU systems)
|
|
|
|
{
|
2024-07-26 23:07:07 +00:00
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
pkgs,
|
|
|
|
...
|
|
|
|
}: let
|
|
|
|
dev = config.myOptions.device;
|
|
|
|
in {
|
2024-05-15 18:29:28 +00:00
|
|
|
config = lib.mkIf (dev.gpu.type == "amd") {
|
|
|
|
services.xserver.videoDrivers = lib.mkDefault ["modesetting" "amdgpu"];
|
|
|
|
|
|
|
|
boot = {
|
2024-07-26 23:07:07 +00:00
|
|
|
initrd.kernelModules = ["amdgpu"]; # load amdgpu kernel module as early as initrd
|
2024-05-15 18:29:28 +00:00
|
|
|
kernelModules = ["amdgpu"]; # if loading somehow fails during initrd but the boot continues, try again later
|
|
|
|
};
|
|
|
|
|
|
|
|
environment.systemPackages = with pkgs; [
|
|
|
|
mesa
|
|
|
|
|
|
|
|
vulkan-tools
|
|
|
|
vulkan-loader
|
|
|
|
vulkan-validation-layers
|
|
|
|
vulkan-extension-layer
|
|
|
|
];
|
|
|
|
|
2024-07-07 17:26:10 +00:00
|
|
|
hardware = {
|
|
|
|
graphics = {
|
|
|
|
enable = true;
|
2024-05-15 18:29:28 +00:00
|
|
|
|
2024-07-26 23:07:07 +00:00
|
|
|
extraPackages = with pkgs; [
|
2024-07-08 12:58:39 +00:00
|
|
|
# Enable AMDVLK (AMD's open-source Vulkan driver)
|
|
|
|
amdvlk
|
|
|
|
|
|
|
|
# OpenCL (Universal GPU computing API - not AMD specific)
|
|
|
|
# To check if this works, run: `nix run nixpkgs#clinfo` (after rebooting)
|
|
|
|
rocmPackages.clr.icd
|
|
|
|
];
|
|
|
|
# AMDVLK for 32-bit applications
|
2024-07-26 23:07:07 +00:00
|
|
|
extraPackages32 = with pkgs; [driversi686Linux.amdvlk];
|
2024-07-07 17:26:10 +00:00
|
|
|
};
|
2024-05-15 18:29:28 +00:00
|
|
|
};
|
2024-07-07 17:26:10 +00:00
|
|
|
|
|
|
|
# HIP (SDK that allows running CUDA code on AMD GPUs)
|
|
|
|
# Most software has the paths hard-coded
|
|
|
|
systemd.tmpfiles.rules = [
|
2024-07-26 23:07:07 +00:00
|
|
|
"L+ /opt/rocm/hip - - - - ${pkgs.rocmPackages.clr}"
|
2024-07-07 17:26:10 +00:00
|
|
|
];
|
2024-05-15 18:29:28 +00:00
|
|
|
};
|
|
|
|
}
|