1{ lib, fetchFromGitHub, cmake, pkg-config, mkDerivation
2, qtbase, qtx11extras, qtsvg, makeWrapper
3, vulkan-loader, libglvnd, xorg, python3, python3Packages
4, bison, pcre, automake, autoconf, addOpenGLRunpath
5, waylandSupport ? false, wayland
6}:
7let
8 custom_swig = fetchFromGitHub {
9 owner = "baldurk";
10 repo = "swig";
11 rev = "renderdoc-modified-7";
12 sha256 = "15r2m5kcs0id64pa2fsw58qll3jyh71jzc04wy20pgsh2326zis6";
13 };
14 cmakeBool = b: if b then "ON" else "OFF";
15in
16mkDerivation rec {
17 pname = "renderdoc";
18 version = "1.16";
19
20 src = fetchFromGitHub {
21 owner = "baldurk";
22 repo = "renderdoc";
23 rev = "v${version}";
24 sha256 = "150d1qzjs420clqr48gickiw5ymjx4md6iyjbxmxsdml0pyxpwwn";
25 };
26
27 buildInputs = [
28 qtbase qtsvg xorg.libpthreadstubs xorg.libXdmcp qtx11extras vulkan-loader python3
29 ] # ++ (with python3Packages; [pyside2 pyside2-tools shiboken2])
30 # TODO: figure out how to make cmake recognise pyside2
31 ++ lib.optional waylandSupport wayland;
32
33 nativeBuildInputs = [ cmake makeWrapper pkg-config bison pcre automake autoconf addOpenGLRunpath ];
34
35 postUnpack = ''
36 cp -r ${custom_swig} swig
37 chmod -R +w swig
38 patchShebangs swig/autogen.sh
39 '';
40
41 cmakeFlags = [
42 "-DBUILD_VERSION_HASH=${src.rev}"
43 "-DBUILD_VERSION_DIST_NAME=NixOS"
44 "-DBUILD_VERSION_DIST_VER=${version}"
45 "-DBUILD_VERSION_DIST_CONTACT=https://github.com/NixOS/nixpkgs/tree/master/pkgs/applications/graphics/renderdoc"
46 "-DBUILD_VERSION_STABLE=ON"
47 "-DENABLE_WAYLAND=${cmakeBool waylandSupport}"
48 ];
49
50 # TODO: define these in the above array via placeholders, once those are widely supported
51 preConfigure = ''
52 cmakeFlags+=" -DVULKAN_LAYER_FOLDER=$out/share/vulkan/implicit_layer.d/"
53 cmakeFlags+=" -DRENDERDOC_SWIG_PACKAGE=$PWD/../swig"
54 '';
55
56 dontWrapQtApps = true;
57 preFixup = ''
58 wrapQtApp $out/bin/qrenderdoc --suffix LD_LIBRARY_PATH : "$out/lib:${vulkan-loader}/lib:${libglvnd}/lib"
59 wrapProgram $out/bin/renderdoccmd --suffix LD_LIBRARY_PATH : "$out/lib:${vulkan-loader}/lib:${libglvnd}/lib"
60 '';
61
62 # The only documentation for this so far is in pkgs/build-support/add-opengl-runpath/setup-hook.sh
63 postFixup = ''
64 addOpenGLRunpath $out/lib/librenderdoc.so
65 '';
66
67 meta = with lib; {
68 description = "A single-frame graphics debugger";
69 homepage = "https://renderdoc.org/";
70 license = licenses.mit;
71 longDescription = ''
72 RenderDoc is a free MIT licensed stand-alone graphics debugger that
73 allows quick and easy single-frame capture and detailed introspection
74 of any application using Vulkan, D3D11, OpenGL or D3D12 across
75 Windows 7 - 10, Linux or Android.
76 '';
77 maintainers = [ maintainers.jansol ];
78 platforms = [ "i686-linux" "x86_64-linux" ];
79 };
80}