1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5 buildPackages,
6 cmake,
7 pkg-config,
8 python3,
9 glslang,
10 libffi,
11 libX11,
12 libXau,
13 libxcb,
14 libXdmcp,
15 libXrandr,
16 vulkan-headers,
17 vulkan-loader,
18 vulkan-volk,
19 wayland,
20 wayland-protocols,
21 wayland-scanner,
22 moltenvk,
23}:
24
25stdenv.mkDerivation rec {
26 pname = "vulkan-tools";
27 version = "1.4.313.0";
28
29 src = fetchFromGitHub {
30 owner = "KhronosGroup";
31 repo = "Vulkan-Tools";
32 rev = "vulkan-sdk-${version}";
33 hash = "sha256-47RVuhK9NDtOazG4awTjwbZSnG+thGw6GpyKmcCgWpQ=";
34 };
35
36 patches = [ ./wayland-scanner.patch ];
37
38 nativeBuildInputs = [
39 cmake
40 pkg-config
41 python3
42 wayland-scanner
43 ];
44
45 buildInputs = [
46 glslang
47 vulkan-headers
48 vulkan-loader
49 vulkan-volk
50 ]
51 ++ lib.optionals (!stdenv.hostPlatform.isDarwin) [
52 libffi
53 libX11
54 libXau
55 libxcb
56 libXdmcp
57 libXrandr
58 wayland
59 wayland-protocols
60 ]
61 ++ lib.optionals stdenv.hostPlatform.isDarwin [
62 moltenvk
63 moltenvk.dev
64 ];
65
66 libraryPath = lib.strings.makeLibraryPath [ vulkan-loader ];
67
68 dontPatchELF = true;
69
70 env.PKG_CONFIG_WAYLAND_SCANNER_WAYLAND_SCANNER = lib.getExe buildPackages.wayland-scanner;
71
72 cmakeFlags = [
73 # Temporarily disabled, see https://github.com/KhronosGroup/Vulkan-Tools/issues/1130
74 # FIXME: remove when fixed upstream
75 "-DBUILD_CUBE=OFF"
76 # Don't build the mock ICD as it may get used instead of other drivers, if installed
77 "-DBUILD_ICD=OFF"
78 # vulkaninfo loads libvulkan using dlopen, so we have to add it manually to RPATH
79 "-DCMAKE_INSTALL_RPATH=${libraryPath}"
80 "-DGLSLANG_INSTALL_DIR=${glslang}"
81 # Hide dev warnings that are useless for packaging
82 "-Wno-dev"
83 ]
84 ++ lib.optionals stdenv.hostPlatform.isDarwin [
85 "-DMOLTENVK_REPO_ROOT=${moltenvk}/share/vulkan/icd.d"
86 # Don’t build the cube demo because it requires `ibtool`, which is not available in nixpkgs.
87 "-DBUILD_CUBE=OFF"
88 ];
89
90 meta = with lib; {
91 description = "Khronos official Vulkan Tools and Utilities";
92 longDescription = ''
93 This project provides Vulkan tools and utilities that can assist
94 development by enabling developers to verify their applications correct
95 use of the Vulkan API.
96 '';
97 homepage = "https://github.com/KhronosGroup/Vulkan-Tools";
98 platforms = platforms.unix;
99 license = licenses.asl20;
100 maintainers = [ maintainers.ralith ];
101 };
102}