1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
|
{
lib,
addDriverRunpath,
autoconf,
automake,
bison,
cmake,
fetchFromGitHub,
fetchpatch,
libxdmcp,
libglvnd,
libpthread-stubs,
makeWrapper,
nix-update-script,
pcre2,
pkg-config,
python3,
qt5,
stdenv,
vulkan-loader,
wayland,
# Boolean flags
waylandSupport ? true,
}:
let
# forked from swig v3 in 2017
# primarily to include https://github.com/swig/swig/pull/251
# (cherry-picked as https://github.com/swig/swig/commit/8d79491a329825ad24294509fc6a0b0a0b8947c4)
custom_swig = fetchFromGitHub {
owner = "baldurk";
repo = "swig";
rev = "renderdoc-modified-7";
hash = "sha256-RsdvxBBQvwuE5wSwL8OBXg5KMSpcO6EuMS0CzWapIpc=";
};
in
stdenv.mkDerivation (finalAttrs: {
pname = "renderdoc";
version = "1.46";
src = fetchFromGitHub {
owner = "baldurk";
repo = "renderdoc";
rev = "v${finalAttrs.version}";
hash = "sha256-NW0gqSTKL5X6PWda/l/+qjdENySwh9dmD4k5CBr2kG0=";
};
outputs = [
"out"
"dev"
"doc"
];
# https://github.com/baldurk/renderdoc/issues/2945
# https://github.com/baldurk/renderdoc/issues/3902
patches = [
# custom revert of
# https://github.com/baldurk/renderdoc/commit/adf8acbccd642c8bc62256fb5580795320364895
./remove-pcre.patch
];
swig_patches = [
# use PCRE2 instead of PCRE
(fetchpatch {
name = "renderdoc-swig-pcre2-1.patch";
url = "https://src.fedoraproject.org/rpms/renderdoc/raw/19ce666d120a229e5c1ab62fc142610ab3b21b3c/f/renderdoc-swig-pcre2-1.patch";
hash = "sha256-xuqHu72vAbxFELNTfJT5SbQOsnG/ee++MZgpuEGLT/w=";
})
(fetchpatch {
name = "renderdoc-swig-pcre2-2.patch";
url = "https://src.fedoraproject.org/rpms/renderdoc/raw/19ce666d120a229e5c1ab62fc142610ab3b21b3c/f/renderdoc-swig-pcre2-2.patch";
hash = "sha256-LUm5Ekmccy4x+hR+iK49zJc75VxuhDhpNw8rkVnn4rc=";
})
];
postPatch = ''
pushd ../swig
prePatch="" postPatch="" patches="$swig_patches" runPhase patchPhase
popd
'';
buildInputs = [
libxdmcp
libpthread-stubs
qt5.qtbase
qt5.qtsvg
vulkan-loader
# TODO: make sure pyrenderdoc is installed properly
# TODO: unbreak shiboken2 on python>3.12
# python312Packages.pyside2
# python312Packages.pyside2-tools
# python312Packages.shiboken2
]
++ lib.optionals waylandSupport [
wayland
];
nativeBuildInputs = [
addDriverRunpath
autoconf
automake
bison
cmake
makeWrapper
pcre2
pkg-config
python3
qt5.qtx11extras
qt5.wrapQtAppsHook
];
cmakeFlags = [
(lib.cmakeFeature "BUILD_VERSION_HASH" finalAttrs.src.rev)
(lib.cmakeFeature "BUILD_VERSION_DIST_NAME" "NixOS")
(lib.cmakeFeature "BUILD_VERSION_DIST_VER" finalAttrs.version)
(lib.cmakeFeature "BUILD_VERSION_DIST_CONTACT" "https://github.com/NixOS/nixpkgs/")
(lib.cmakeBool "BUILD_VERSION_STABLE" true)
(lib.cmakeBool "ENABLE_UNSUPPORTED_EXPERIMENTAL_POSSIBLY_BROKEN_WAYLAND" waylandSupport)
# TODO: build python bindings
# https://github.com/NixOS/nixpkgs/issues/525939
(lib.cmakeBool "ENABLE_PYRENDERDOC" false)
(lib.cmakeBool "QRENDERDOC_ENABLE_PYSIDE2" false)
];
dontWrapQtApps = true;
strictDeps = true;
postUnpack = ''
cp -r ${finalAttrs.passthru.custom_swig} swig
chmod -R +w swig
patchShebangs swig/autogen.sh
'';
# TODO: define these in the above array via placeholders, once those are
# widely supported
preConfigure = ''
cmakeFlagsArray+=(
"-DRENDERDOC_SWIG_PACKAGE=$PWD/../swig"
"-DVULKAN_LAYER_FOLDER=$out/share/vulkan/implicit_layer.d/"
)
'';
postInstall = ''
substituteInPlace $out/share/thumbnailers/renderdoc.thumbnailer \
--replace-fail "TryExec=/usr/bin/renderdoccmd" "TryExec=$out/bin/renderdoccmd" \
--replace-fail "Exec=/usr/bin/renderdoccmd" "Exec=$out/bin/renderdoccmd"
'';
preFixup =
let
libPath = lib.makeLibraryPath [
libglvnd
vulkan-loader
];
in
''
wrapQtApp $out/bin/qrenderdoc \
--set QT_QPA_PLATFORM "wayland;xcb" \
--suffix LD_LIBRARY_PATH : "$out/lib:${libPath}"
wrapProgram $out/bin/renderdoccmd \
--suffix LD_LIBRARY_PATH : "$out/lib:${libPath}"
'';
# The only documentation for this so far is in the setup-hook.sh script from
# add-opengl-runpath
postFixup = ''
addDriverRunpath $out/lib/librenderdoc.so
'';
passthru = {
inherit custom_swig;
updateScript = nix-update-script { };
};
meta = {
homepage = "https://renderdoc.org/";
description = "Single-frame graphics debugger";
longDescription = ''
RenderDoc is a free MIT licensed stand-alone graphics debugger that
allows quick and easy single-frame capture and detailed introspection
of any application using Vulkan, D3D11, OpenGL or D3D12 across
Windows 7 - 10, Linux or Android.
'';
license = lib.licenses.mit;
mainProgram = "renderdoccmd";
maintainers = with lib.maintainers; [
pbsds
ShyAssassin
];
platforms = lib.intersectLists lib.platforms.linux (
lib.platforms.x86_64 ++ lib.platforms.i686 ++ lib.platforms.aarch64
);
};
})
|