From 5af4dc5d52a306272f4d4a97079aeef3888ae210 Mon Sep 17 00:00:00 2001 From: ChaosAttractor <46527539+LostAttractor@users.noreply.github.com> Date: Sat, 28 Jan 2023 23:46:56 +0800 Subject: [PATCH] Add the option of whether to install the opencl environment and whether to use amdvlk for amdgpu --- common/gpu/amd/default.nix | 37 +++++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/common/gpu/amd/default.nix b/common/gpu/amd/default.nix index 91ba0b7..e86bb01 100644 --- a/common/gpu/amd/default.nix +++ b/common/gpu/amd/default.nix @@ -6,11 +6,30 @@ ) // { default = true; }; + options.hardware.amdgpu.amdvlk = lib.mkEnableOption (lib.mdDoc + "use amdvlk drivers instead mesa radv drivers" + ) // { + default = true; + }; + options.hardware.amdgpu.opencl = lib.mkEnableOption (lib.mdDoc + "rocm opencl runtime (Install rocm-opencl-icd and rocm-opencl-runtime)" + ) // { + default = true; + }; config = lib.mkMerge [ { services.xserver.videoDrivers = lib.mkDefault [ "amdgpu" ]; - + + hardware.opengl = { + driSupport = lib.mkDefault true; + driSupport32Bit = lib.mkDefault true; + }; + } + (lib.mkIf config.hardware.amdgpu.loadInInitrd { + boot.initrd.kernelModules = [ "amdgpu" ]; + }) + (lib.mkIf config.hardware.amdgpu.amdvlk { hardware.opengl.extraPackages = with pkgs; [ rocm-opencl-icd rocm-opencl-runtime @@ -20,16 +39,14 @@ hardware.opengl.extraPackages32 = with pkgs; [ driversi686Linux.amdvlk ]; - - hardware.opengl = { - driSupport = lib.mkDefault true; - driSupport32Bit = lib.mkDefault true; - }; - + environment.variables.AMD_VULKAN_ICD = lib.mkDefault "RADV"; - } - (lib.mkIf config.hardware.amdgpu.loadInInitrd { - boot.initrd.kernelModules = [ "amdgpu" ]; + }) + (lib.mkIf config.hardware.amdgpu.opencl { + hardware.opengl.extraPackages = with pkgs; [ + rocm-opencl-icd + rocm-opencl-runtime + ]; }) ]; }