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