mirror of
				https://github.com/NixOS/nixos-hardware.git
				synced 2025-11-04 17:27:14 +08:00 
			
		
		
		
	Add the option of whether to install the opencl environment and whether to use amdvlk for amdgpu
This commit is contained in:
		@@ -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
 | 
			
		||||
@@ -21,15 +40,13 @@
 | 
			
		||||
        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
 | 
			
		||||
      ];
 | 
			
		||||
    })
 | 
			
		||||
  ];
 | 
			
		||||
} 
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user