1{ lib
2, stdenv
3, fetchFromGitHub
4, cmake
5, pkg-config
6, python3
7, glslang
8, libffi
9, libX11
10, libXau
11, libxcb
12, libXdmcp
13, libXrandr
14, vulkan-headers
15, vulkan-loader
16, wayland
17, wayland-protocols
18, moltenvk
19, AppKit
20, Cocoa
21}:
22
23stdenv.mkDerivation rec {
24 pname = "vulkan-tools";
25 version = "1.3.268.0";
26
27 src = fetchFromGitHub {
28 owner = "KhronosGroup";
29 repo = "Vulkan-Tools";
30 rev = "vulkan-sdk-${version}";
31 hash = "sha256-IsMxiAR4ak6kC3BNYhtI+JVNkEka4ZceSElxk39THXg=";
32 };
33
34 nativeBuildInputs = [
35 cmake
36 pkg-config
37 python3
38 ];
39
40 buildInputs = [
41 glslang
42 vulkan-headers
43 vulkan-loader
44 ] ++ lib.optionals (!stdenv.isDarwin) [
45 libffi
46 libX11
47 libXau
48 libxcb
49 libXdmcp
50 libXrandr
51 wayland
52 wayland-protocols
53 ] ++ lib.optionals stdenv.isDarwin [
54 moltenvk
55 moltenvk.dev
56 AppKit
57 Cocoa
58 ];
59
60 postPatch = lib.optionalString stdenv.isDarwin ''
61 # Modify mac_common.cmake to find the ICD where nixpkgs puts it.
62 substituteInPlace mac_common.cmake \
63 --replace MoltenVK/icd/MoltenVK_icd.json MoltenVK_icd.json
64 # Remove the unconditional check for `ibtool` since the cube demo that needs it won’t be built.
65 sed -e '/#.*Interface Builder/,/^endif()/d' -i mac_common.cmake
66 # Install `vulkaninfo` to $out/bin even on Darwin.
67 substituteInPlace vulkaninfo/CMakeLists.txt \
68 --replace 'install(TARGETS vulkaninfo RUNTIME DESTINATION "vulkaninfo")' 'install(TARGETS vulkaninfo)'
69 '';
70
71 libraryPath = lib.strings.makeLibraryPath [ vulkan-loader ];
72
73 dontPatchELF = true;
74
75 cmakeFlags = [
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 "-DPKG_CONFIG_EXECUTABLE=${pkg-config}/bin/pkg-config"
81 "-DGLSLANG_INSTALL_DIR=${glslang}"
82 # Hide dev warnings that are useless for packaging
83 "-Wno-dev"
84 ] ++ lib.optionals stdenv.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}