nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 fetchurl,
5 fetchpatch,
6 replaceVars,
7 meson,
8 ninja,
9 gettext,
10 pkg-config,
11 python3,
12 gst-plugins-base,
13 orc,
14 gstreamer,
15 gobject-introspection,
16 wayland-scanner,
17 enableZbar ? false,
18 faacSupport ? false,
19 faac,
20 opencvSupport ? false,
21 opencv4,
22 faad2,
23 # Enabling lcevcdecoder currently causes issues when attempting to decode regular h264 data
24 # warning: No decoder available for type 'video/x-h264, stream-format=(string)avc, [...], lcevc=(boolean)false, [...]
25 lcevcdecSupport ? false,
26 lcevcdec,
27 ldacbtSupport ? lib.meta.availableOn stdenv.hostPlatform ldacbt,
28 ldacbt,
29 liblc3,
30 libass,
31 lrdf,
32 ladspaH,
33 lcms2,
34 libnice,
35 webrtcAudioProcessingSupport ? lib.meta.availableOn stdenv.hostPlatform webrtc-audio-processing_1,
36 webrtc-audio-processing_1,
37 lilv,
38 lv2,
39 serd,
40 sord,
41 sratom,
42 libbs2b,
43 libmodplug,
44 libmpeg2,
45 libmicrodns,
46 openjpeg,
47 libopus,
48 librsvg,
49 bluez,
50 chromaprint,
51 curl,
52 fdk_aac,
53 flite,
54 gsm,
55 json-glib,
56 ajaSupport ? lib.meta.availableOn stdenv.hostPlatform libajantv2,
57 libajantv2,
58 libaom,
59 libdc1394,
60 libde265,
61 libdrm,
62 libdvdnav,
63 libdvdread,
64 libgudev,
65 qrencode,
66 libsndfile,
67 libusb1,
68 neon,
69 openal,
70 openexr,
71 openh264Support ? lib.meta.availableOn stdenv.hostPlatform openh264,
72 openh264,
73 libopenmpt,
74 pango,
75 rtmpdump,
76 sbc,
77 soundtouch,
78 spandsp,
79 srtp,
80 zbar,
81 wayland-protocols,
82 wildmidi,
83 svt-av1,
84 fluidsynth,
85 libva,
86 wayland,
87 libwebp,
88 gnutls,
89 mjpegtools,
90 libGL,
91 addDriverRunpath,
92 gtk3,
93 libintl,
94 game-music-emu,
95 openssl,
96 x265,
97 libxml2,
98 srt,
99 vo-aacenc,
100 libfreeaptx,
101 zxing-cpp,
102 usrsctp,
103 directoryListingUpdater,
104 enableGplPlugins ? true,
105 bluezSupport ? stdenv.hostPlatform.isLinux,
106 # Causes every application using GstDeviceMonitor to send mDNS queries every 2 seconds
107 microdnsSupport ? false,
108 # Checks meson.is_cross_build(), so even canExecute isn't enough.
109 enableDocumentation ? stdenv.hostPlatform == stdenv.buildPlatform,
110 hotdoc,
111 guiSupport ? true,
112 gst-plugins-bad,
113 apple-sdk_gstreamer,
114}:
115
116stdenv.mkDerivation (finalAttrs: {
117 pname = "gst-plugins-bad";
118 version = "1.26.5";
119
120 outputs = [
121 "out"
122 "dev"
123 ];
124
125 src = fetchurl {
126 url = "https://gstreamer.freedesktop.org/src/gst-plugins-bad/gst-plugins-bad-${finalAttrs.version}.tar.xz";
127 hash = "sha256-mJDyYvOyqVZNy2KenraX13uT0fcYl+2hqBcLfc/nMpQ=";
128 };
129
130 patches = [
131 # Add fallback paths for nvidia userspace libraries
132 (replaceVars ./fix-paths.patch {
133 inherit (addDriverRunpath) driverLink;
134 })
135 ];
136
137 nativeBuildInputs = [
138 meson
139 ninja
140 pkg-config
141 orc # for orcc
142 python3
143 gettext
144 gstreamer # for gst-tester-1.0
145 gobject-introspection
146 ]
147 ++ lib.optionals enableDocumentation [
148 hotdoc
149 ]
150 ++ lib.optionals (gst-plugins-base.waylandEnabled && stdenv.hostPlatform.isLinux) [
151 wayland-scanner
152 ];
153
154 buildInputs = [
155 gst-plugins-base
156 orc
157 json-glib
158 lcms2
159 liblc3
160 libass
161 libbs2b
162 libmodplug
163 openjpeg
164 libopenmpt
165 libopus
166 librsvg
167 curl.dev
168 fdk_aac
169 gsm
170 libaom
171 libdc1394
172 libde265
173 libdvdnav
174 libdvdread
175 libnice
176 qrencode
177 libsndfile
178 libusb1
179 neon
180 openal
181 openexr
182 rtmpdump
183 pango
184 soundtouch
185 srtp
186 fluidsynth
187 libwebp
188 gnutls
189 game-music-emu
190 openssl
191 libxml2
192 libintl
193 srt
194 vo-aacenc
195 libfreeaptx
196 zxing-cpp
197 usrsctp
198 wildmidi
199 svt-av1
200 ]
201 ++ lib.optionals opencvSupport [
202 opencv4
203 ]
204 ++ lib.optionals enableZbar [
205 zbar
206 ]
207 ++ lib.optionals faacSupport [
208 faac
209 ]
210 ++ lib.optionals enableGplPlugins [
211 libmpeg2
212 mjpegtools
213 faad2
214 x265
215 ]
216 ++ lib.optionals bluezSupport [
217 bluez
218 ]
219 ++ lib.optionals microdnsSupport [
220 libmicrodns
221 ]
222 ++ lib.optionals openh264Support [
223 openh264
224 ]
225 ++ lib.optionals ajaSupport [
226 libajantv2
227 ]
228 ++ lib.optionals (gst-plugins-base.waylandEnabled && stdenv.hostPlatform.isLinux) [
229 libva # vaapi requires libva -> libdrm -> libpciaccess, which is Linux-only in nixpkgs
230 wayland
231 wayland-protocols
232 ]
233 ++ lib.optionals (!stdenv.hostPlatform.isDarwin) [
234 # TODO: mjpegtools uint64_t is not compatible with guint64 on Darwin
235 mjpegtools
236
237 chromaprint
238 flite
239 libdrm
240 libgudev
241 sbc
242 spandsp
243
244 # ladspa plug-in
245 ladspaH
246 lrdf # TODO: make build on Darwin
247
248 # lv2 plug-in
249 lilv
250 lv2
251 serd
252 sord
253 sratom
254
255 libGL
256 ]
257 ++ lib.optionals guiSupport [
258 gtk3
259 ]
260 ++ lib.optionals lcevcdecSupport [
261 lcevcdec
262 ]
263 ++ lib.optionals ldacbtSupport [
264 ldacbt
265 ]
266 ++ lib.optionals webrtcAudioProcessingSupport [
267 webrtc-audio-processing_1
268 ]
269 ++ lib.optionals stdenv.hostPlatform.isDarwin [
270 apple-sdk_gstreamer
271 ];
272
273 mesonFlags = [
274 "-Dexamples=disabled" # requires many dependencies and probably not useful for our users
275 "-Dglib_debug=disabled" # cast checks should be disabled on stable releases
276
277 "-Damfcodec=disabled" # Windows-only
278 "-Dandroidmedia=disabled" # Requires Android system.
279 "-Davtp=disabled"
280 "-Dcuda-nvmm=disabled"
281 "-Ddirectshow=disabled" # Windows-only
282 "-Dqt6d3d11=disabled" # Windows-only
283 "-Ddts=disabled" # required `libdca` library not packaged in nixpkgs as of writing, and marked as "BIG FAT WARNING: libdca is still in early development"
284 "-Dzbar=${if enableZbar then "enabled" else "disabled"}"
285 "-Dfaac=${if faacSupport then "enabled" else "disabled"}"
286 "-Diqa=disabled" # required `dssim` library not packaging in nixpkgs as of writing, also this is AGPL so update license when adding support
287 "-Dlcevcencoder=disabled" # not packaged in nixpkgs as of writing
288 "-Dmagicleap=disabled" # required `ml_audio` library not packaged in nixpkgs as of writing
289 "-Dmsdk=disabled" # not packaged in nixpkgs as of writing / no Windows support
290 # As of writing, with `libmpcdec` in `buildInputs` we get
291 # "Could not find libmpcdec header files, but Musepack was enabled via options"
292 # This is likely because nixpkgs has the header in libmpc/mpcdec.h
293 # instead of mpc/mpcdec.h, like Arch does. The situation is not trivial.
294 # There are apparently 2 things called `libmpcdec` from the same author:
295 # * http://svn.musepack.net/libmpcdec/trunk/src/
296 # * http://svn.musepack.net/libmpc/trunk/include/mpc/
297 # Fixing it likely requires to first figure out with upstream which one
298 # is needed, and then patching upstream to find it (though it probably
299 # already works on Arch?).
300 "-Dmusepack=disabled"
301 "-Dnvcomp=disabled"
302 "-Dnvdswrapper=disabled"
303 "-Dopenni2=disabled" # not packaged in nixpkgs as of writing
304 "-Dopensles=disabled" # not packaged in nixpkgs as of writing
305 "-Dsvthevcenc=disabled" # required `SvtHevcEnc` library not packaged in nixpkgs as of writing
306 "-Dsvtjpegxs=disabled" # not packaged in nixpkgs as of writing
307 "-Dteletext=disabled" # required `zvbi` library not packaged in nixpkgs as of writing
308 "-Dtinyalsa=disabled" # not packaged in nixpkgs as of writing
309 "-Dvoamrwbenc=disabled" # required `vo-amrwbenc` library not packaged in nixpkgs as of writing
310 "-Dvulkan=disabled" # Linux-only, and we haven't figured out yet which of the vulkan nixpkgs it needs
311 "-Dwasapi=disabled" # not packaged in nixpkgs as of writing / no Windows support
312 "-Dwasapi2=disabled" # not packaged in nixpkgs as of writing / no Windows support
313 "-Dwpe=disabled" # required `wpe-webkit` library not packaged in nixpkgs as of writing
314 "-Dgs=disabled" # depends on `google-cloud-cpp`
315 "-Donnx=disabled" # depends on `libonnxruntime` not packaged in nixpkgs as of writing
316 "-Dopenaptx=enabled" # since gstreamer-1.20.1 `libfreeaptx` is supported for circumventing the dubious license conflict with `libopenaptx`
317 "-Dopencv=${if opencvSupport then "enabled" else "disabled"}" # Reduces rebuild size when `config.cudaSupport = true`
318 "-Daja=${if ajaSupport then "enabled" else "disabled"}"
319 "-Dmicrodns=${if microdnsSupport then "enabled" else "disabled"}"
320 "-Dbluez=${if bluezSupport then "enabled" else "disabled"}"
321 (lib.mesonEnable "openh264" openh264Support)
322 (lib.mesonEnable "doc" enableDocumentation)
323 (lib.mesonEnable "directfb" false)
324 (lib.mesonEnable "lcevcdecoder" lcevcdecSupport)
325 (lib.mesonEnable "ldac" ldacbtSupport)
326 (lib.mesonEnable "webrtcdsp" webrtcAudioProcessingSupport)
327 (lib.mesonEnable "isac" webrtcAudioProcessingSupport)
328 ]
329 ++ lib.optionals (!stdenv.hostPlatform.isLinux) [
330 "-Ddoc=disabled" # needs gstcuda to be enabled which is Linux-only
331 ]
332 ++ lib.optionals (!stdenv.hostPlatform.isLinux || !stdenv.hostPlatform.isx86) [
333 "-Dnvcodec=disabled" # Linux-only, broken on non-x86
334 ]
335 ++ lib.optionals (!stdenv.hostPlatform.isLinux || !gst-plugins-base.waylandEnabled) [
336 "-Dva=disabled" # see comment on `libva` in `buildInputs`
337 ]
338 ++ lib.optionals stdenv.hostPlatform.isDarwin [
339 "-Daja=disabled"
340 "-Dchromaprint=disabled"
341 "-Dflite=disabled"
342 "-Dkms=disabled" # renders to libdrm output
343 "-Dlv2=disabled"
344 "-Dsbc=disabled"
345 "-Dspandsp=disabled"
346 "-Ddvb=disabled"
347 "-Dfbdev=disabled"
348 "-Duvcgadget=disabled" # requires gudev
349 "-Duvch264=disabled" # requires gudev
350 "-Dv4l2codecs=disabled" # requires gudev
351 "-Dladspa=disabled" # requires lrdf
352 ]
353 ++
354 lib.optionals
355 (!stdenv.hostPlatform.isLinux || !stdenv.hostPlatform.isx86_64 || !gst-plugins-base.waylandEnabled)
356 [
357 "-Dqsv=disabled" # Linux (and Windows) x86 only, makes va required
358 ]
359 ++ lib.optionals (!gst-plugins-base.glEnabled) [
360 "-Dgl=disabled"
361 ]
362 ++ lib.optionals (!gst-plugins-base.waylandEnabled || !guiSupport) [
363 "-Dgtk3=disabled" # Wayland-based GTK sink
364 "-Dwayland=disabled"
365 ]
366 ++ lib.optionals (!gst-plugins-base.glEnabled) [
367 # `applemedia/videotexturecache.h` requires `gst/gl/gl.h`,
368 # but its meson build system does not declare the dependency.
369 "-Dapplemedia=disabled"
370 ]
371 ++ (
372 if enableGplPlugins then
373 [
374 "-Dgpl=enabled"
375 ]
376 else
377 [
378 "-Ddts=disabled"
379 "-Dfaad=disabled"
380 "-Diqa=disabled"
381 "-Dmpeg2enc=disabled"
382 "-Dmplex=disabled"
383 "-Dresindvd=disabled"
384 "-Dx265=disabled"
385 ]
386 );
387
388 # Argument list too long
389 strictDeps = true;
390
391 postPatch = ''
392 patchShebangs \
393 scripts/extract-release-date-from-doap-file.py
394 '';
395
396 # This package has some `_("string literal")` string formats
397 # that trip up clang with format security enabled.
398 hardeningDisable = [ "format" ];
399
400 doCheck = false; # fails 20 out of 58 tests, expensive
401
402 preFixup = ''
403 moveToOutput "lib/gstreamer-1.0/pkgconfig" "$dev"
404 '';
405
406 passthru = {
407 tests = {
408 full = gst-plugins-bad.override {
409 enableZbar = true;
410 faacSupport = true;
411 opencvSupport = true;
412 };
413
414 lgplOnly = gst-plugins-bad.override {
415 enableGplPlugins = false;
416 };
417 };
418
419 updateScript = directoryListingUpdater { };
420 };
421
422 meta = {
423 description = "GStreamer Bad Plugins";
424 mainProgram = "gst-transcoder-1.0";
425 homepage = "https://gstreamer.freedesktop.org";
426 longDescription = ''
427 a set of plug-ins that aren't up to par compared to the
428 rest. They might be close to being good quality, but they're missing
429 something - be it a good code review, some documentation, a set of tests,
430 a real live maintainer, or some actual wide use.
431 '';
432 license = if enableGplPlugins then lib.licenses.gpl2Plus else lib.licenses.lgpl2Plus;
433 platforms = lib.platforms.linux ++ lib.platforms.darwin;
434 maintainers = [ ];
435 };
436})