1{
2 stdenv,
3 fetchFromGitHub,
4 lib,
5 cmake,
6 makeWrapper,
7 pkg-config,
8 python3,
9 wayland,
10 libX11,
11 libxcb,
12 lz4,
13 vulkan-loader,
14 xcbutilkeysyms,
15 zlib,
16 zstd,
17}:
18
19stdenv.mkDerivation rec {
20 pname = "gfxreconstruct";
21 version = "1.0.4";
22
23 src = fetchFromGitHub {
24 owner = "LunarG";
25 repo = "gfxreconstruct";
26 rev = "v${version}";
27 hash = "sha256-MuCdJoBFxKwDCOCltlU3oBS9elFS6F251dHjHcIb4Jg=";
28 fetchSubmodules = true;
29 };
30
31 buildInputs = [
32 libX11
33 libxcb
34 lz4
35 python3
36 wayland
37 xcbutilkeysyms
38 zlib
39 zstd
40 ];
41
42 nativeBuildInputs = [
43 cmake
44 makeWrapper
45 pkg-config
46 ];
47
48 # The python script searches in subfolders, but we want to search in the same bin directory
49 prePatch = ''
50 substituteInPlace tools/gfxrecon/gfxrecon.py \
51 --replace "scriptdir, '..', cmd" 'scriptdir'
52 '';
53
54 # Fix the paths to load the layer.
55 # Also remove the .py suffix on files so that gfxrecon
56 # does not try to start the wrapper bash scripts with python.
57 postInstall = ''
58 substituteInPlace $out/share/vulkan/explicit_layer.d/VkLayer_gfxreconstruct.json \
59 --replace 'libVkLayer_gfxreconstruct.so' "$out/lib/libVkLayer_gfxreconstruct.so"
60 for f in $out/bin/*.py; do
61 mv -- "$f" "''${f%%.py}"
62 done
63 wrapProgram $out/bin/gfxrecon-capture-vulkan \
64 --prefix VK_ADD_LAYER_PATH : "$out/share/vulkan/explicit_layer.d"
65 wrapProgram $out/bin/gfxrecon-replay \
66 --prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath [ vulkan-loader ]}
67 '';
68
69 meta = {
70 description = "Graphics API Capture and Replay Tools";
71 homepage = "https://github.com/LunarG/gfxreconstruct/";
72 changelog = "https://github.com/LunarG/gfxreconstruct/releases/tag/v${version}";
73 license = lib.licenses.mit;
74 maintainers = with lib.maintainers; [ Flakebi ];
75 platforms = lib.platforms.linux;
76 };
77}