1{ lib
2, callPackage
3, stdenv
4, fetchFromGitHub
5, cmake
6, pkg-config
7, jq
8, glslang
9, libffi
10, libX11
11, libXau
12, libxcb
13, libXdmcp
14, libXrandr
15, spirv-headers
16, vulkan-headers
17, vulkan-utility-libraries
18, wayland
19}:
20
21let
22 robin-hood-hashing = callPackage ./robin-hood-hashing.nix {};
23in
24stdenv.mkDerivation rec {
25 pname = "vulkan-validation-layers";
26 version = "1.3.283.0";
27
28 src = fetchFromGitHub {
29 owner = "KhronosGroup";
30 repo = "Vulkan-ValidationLayers";
31 rev = "vulkan-sdk-${version}";
32 hash = "sha256-OT9VfGg3+NBVV6SCGZ+Hu9FAxGJXXT45yvt2sHDIFTA=";
33 };
34
35 nativeBuildInputs = [
36 cmake
37 pkg-config
38 jq
39 ];
40
41 buildInputs = [
42 libX11
43 libXau
44 libXdmcp
45 libXrandr
46 libffi
47 libxcb
48 vulkan-headers
49 vulkan-utility-libraries
50 wayland
51 ];
52
53 cmakeFlags = [
54 "-DGLSLANG_INSTALL_DIR=${glslang}"
55 "-DSPIRV_HEADERS_INSTALL_DIR=${spirv-headers}"
56 "-DROBIN_HOOD_HASHING_INSTALL_DIR=${robin-hood-hashing}"
57 "-DBUILD_LAYER_SUPPORT_FILES=ON"
58 "-DPKG_CONFIG_EXECUTABLE=${pkg-config}/bin/pkg-config"
59 # Hide dev warnings that are useless for packaging
60 "-Wno-dev"
61 ];
62
63 # Tests require access to vulkan-compatible GPU, which isn't
64 # available in Nix sandbox. Fails with VK_ERROR_INCOMPATIBLE_DRIVER.
65 doCheck = false;
66
67 separateDebugInfo = true;
68
69 # Include absolute paths to layer libraries in their associated
70 # layer definition json files.
71 preFixup = ''
72 for f in "$out"/share/vulkan/explicit_layer.d/*.json "$out"/share/vulkan/implicit_layer.d/*.json; do
73 jq <"$f" >tmp.json ".layer.library_path = \"$out/lib/\" + .layer.library_path"
74 mv tmp.json "$f"
75 done
76 '';
77
78 meta = with lib; {
79 description = "Official Khronos Vulkan validation layers";
80 homepage = "https://github.com/KhronosGroup/Vulkan-ValidationLayers";
81 platforms = platforms.linux;
82 license = licenses.asl20;
83 maintainers = [ maintainers.ralith ];
84 };
85}