1{ lib
2, callPackage
3, stdenv
4, fetchFromGitHub
5, cmake
6, pkg-config
7, glslang
8, libffi
9, libX11
10, libXau
11, libxcb
12, libXdmcp
13, libXrandr
14, spirv-headers
15, spirv-tools
16, vulkan-headers
17, wayland
18}:
19
20let
21 robin-hood-hashing = callPackage ./robin-hood-hashing.nix {};
22in
23stdenv.mkDerivation rec {
24 pname = "vulkan-validation-layers";
25 version = "1.3.231.0";
26
27 # If we were to use "dev" here instead of headers, the setupHook would be
28 # placed in that output instead of "out".
29 outputs = ["out" "headers"];
30 outputInclude = "headers";
31
32 src = (assert (lib.all (pkg: pkg.version == version) [vulkan-headers glslang spirv-tools spirv-headers]);
33 fetchFromGitHub {
34 owner = "KhronosGroup";
35 repo = "Vulkan-ValidationLayers";
36 rev = "sdk-${version}";
37 hash = "sha256-5bzUauu8081zyRaWmRUtOxHjUU4gc1GWoJtU783Msh0=";
38 });
39
40 # Include absolute paths to layer libraries in their associated
41 # layer definition json files.
42 postPatch = ''
43 sed "s|\([[:space:]]*set(INSTALL_DEFINES \''${INSTALL_DEFINES} -DRELATIVE_LAYER_BINARY=\"\)\(\$<TARGET_FILE_NAME:\''${TARGET_NAME}>\")\)|\1$out/lib/\2|" -i layers/CMakeLists.txt
44 '';
45
46 nativeBuildInputs = [
47 cmake
48 pkg-config
49 ];
50
51 buildInputs = [
52 libX11
53 libXau
54 libXdmcp
55 libXrandr
56 libffi
57 libxcb
58 spirv-tools
59 vulkan-headers
60 wayland
61 ];
62
63 cmakeFlags = [
64 "-DGLSLANG_INSTALL_DIR=${glslang}"
65 "-DSPIRV_HEADERS_INSTALL_DIR=${spirv-headers}"
66 "-DROBIN_HOOD_HASHING_INSTALL_DIR=${robin-hood-hashing}"
67 "-DBUILD_LAYER_SUPPORT_FILES=ON"
68 "-DPKG_CONFIG_EXECUTABLE=${pkg-config}/bin/pkg-config"
69 # Hide dev warnings that are useless for packaging
70 "-Wno-dev"
71 ];
72
73 # Tests require access to vulkan-compatible GPU, which isn't
74 # available in Nix sandbox. Fails with VK_ERROR_INCOMPATIBLE_DRIVER.
75 doCheck = false;
76
77 meta = with lib; {
78 description = "The official Khronos Vulkan validation layers";
79 homepage = "https://github.com/KhronosGroup/Vulkan-ValidationLayers";
80 platforms = platforms.linux;
81 license = licenses.asl20;
82 maintainers = [ maintainers.ralith ];
83 };
84}