Packaging AMDVLK


I would like to contribute packaging AMDVLK:

AMDVLK repo is here:
It uses CMake to build and depends on a bunch of different repos, they’re pulled in according to this definition
The CMake files seem to depend on a certain directory structure
It’s also packaged in AUR: PKGBUILD - aur.git - AUR Package Repositories

I’d love to contribute the needed derivations, I do need some help figuring out:
Should it be possible to reuse existing derivations? ( spirv-headers , spirv-tools , glslang )
What about their fork of llvm-project? – E: this seems to be blocking me right now
I suppose I’ll figure it out today when trying to build
How am I meant to pull in multipe repos in a single derivation?
Installation instructions mention replacing existing icd.json files with the ones provided in the repo, I have a hard time figuring out how this would apply to NixOS – E: vulkan-loader searches through some XDG folders, that should be easy to configure.


Here’s where I am so far:

The build fails due to one error, and I can’t really make sense of it, supposedly related to LLVM:

CMake Error: Could not open file for write in copy operation /build/xgl/build/llvm/lib/cmake/llvm/LLVMConfigVersion.cmake.tmp
CMake Error: : System Error: Permission denied
CMake Error at /build/llvm-project/llvm/cmake/modules/CMakeLists.txt:114 (configure_file):
  configure_file Problem configuring file

-- Failed to find LLVM FileCheck
-- Version: 0.0.0

Logs are included with the gist.

Hi, did you get any further with this?

I currently have the following derivation which does manage to build

{ stdenv, cmake, pkgconfig, wayland, python3, fetchRepoProject, libffi, perl, xorg, openssl }:

stdenv.mkDerivation rec {
  pname = "amdvlk";
  version = "v-2020.Q2.4";

  src = fetchRepoProject {
    name = "amdvlk-src";
    manifest = "";
    rev = "fc576d9b331e8b86c1881f4b2385af8a093baef0";
    sha256 = "0bbpbyxnnl3pxx8aycv59kgilw5m6ddrida1gqfjblhc30mr0ivg";

  preConfigure = ''
    cd drivers/xgl

  cmakeFlags = [

  buildInputs = [

  nativeBuildInputs = [


However I’m struggling to work out how I would actually install the driver


Great job, I’ll be trying it out on my machine shortly.

From what I gathered, vulkan-loader searches for vulkan/icd.d/*.json in $XDG_CONFIG_DIRS, $XDG_DATA_DIRS, $XDG_DATA_HOME and finally /etc, which seems like a fairly easy way to have some NixOS/home-manager module handle that. (possibly outdated source:
That search can be bypassed by using $VK_ICD_FILENAMES and pointing it directly to an ICD .json file.

The default installation phase seems to put LLVM-related stuff in $out, which isn’t what we want.
I have built the derivation in a nix-shell to have access to everything built, drivers/xgl/build/icd/ seems to be the only thing needed.

I made a copy of drivers/AMDVLK/json/Ubuntu/amd_icd64.json and fixed the path to, then set $VK_ICD_FILENAMES to it in order to try it out without a full setup.

With vulkan-tools installed, vulkaninfo returns 255 and prints

/build/source/vulkaninfo/vulkaninfo.h:373: failed with ERROR_OUT_OF_HOST_MEMORY

vkcube returns 1 and prints

vkCreateInstance failed.

Do you have a compatible Vulkan installable client driver (ICD) installed?
Please look at the Getting Started guide for additional information.

Trying with VK_LOADER_DEBUG=all doesn’t seem to show any errors, it even seems to succeed at completing DEBUG: Build ICD instance extension list, and then the crash happens.

It could just be my GPU/setup, I’m running a R9 390 with amdgpu drivers.


After doing this I realised that there is already an open PR for amdvlk . This works perfectly for me on RX 5600xt