opentabletdriver: 0.6.5.0 -> 0.6.5.1 (#379384)
[NixPkgs.git] / pkgs / by-name / vl / vlc / package.nix
blob4b9269bf4b90b8d710a28470b4704209e87e9b09
2   lib,
3   SDL,
4   SDL_image,
5   a52dec,
6   alsa-lib,
7   autoreconfHook,
8   avahi,
9   curl,
10   dbus,
11   faad2,
12   fetchpatch,
13   fetchurl,
14   # Please unpin FFmpeg on the next upstream release.
15   # Currently FFmpeg is pinned to 4.x because VAAPI acceleration is broken when
16   # building with newer versions:
17   # https://code.videolan.org/videolan/vlc/-/issues/26772
18   # This is intentional by upstream but VLC 4.0 will support newer FFmpeg.
19   ffmpeg_4,
20   flac,
21   fluidsynth,
22   freefont_ttf,
23   freetype,
24   fribidi,
25   genericUpdater,
26   gnutls,
27   libSM,
28   libXext,
29   libXinerama,
30   libXpm,
31   libXv,
32   libXvMC,
33   libarchive,
34   libass,
35   libbluray,
36   libcaca,
37   libcddb,
38   libdc1394,
39   libdvbpsi,
40   libdvdnav,
41   libebml,
42   libgcrypt,
43   libgpg-error,
44   libjack2,
45   libkate,
46   libmad,
47   libmatroska,
48   libmicrodns,
49   libmodplug,
50   libmtp,
51   liboggz,
52   libopus,
53   libplacebo_5,
54   libpulseaudio,
55   libraw1394,
56   librsvg,
57   libsForQt5,
58   libsamplerate,
59   libspatialaudio,
60   libssh2,
61   libtheora,
62   libtiger,
63   libupnp,
64   libv4l,
65   libva,
66   libvdpau,
67   libvorbis,
68   libxml2,
69   live555,
70   lua5,
71   mpeg2dec,
72   ncurses,
73   perl,
74   pkg-config,
75   pkgsBuildBuild,
76   protobuf,
77   removeReferencesTo,
78   samba,
79   schroedinger,
80   speex,
81   srt,
82   stdenv,
83   systemd,
84   taglib,
85   unzip,
86   wayland,
87   wayland-protocols,
88   wayland-scanner,
89   wrapGAppsHook3,
90   writeShellScript,
91   xcbutilkeysyms,
92   zlib,
94   chromecastSupport ? true,
95   jackSupport ? false,
96   onlyLibVLC ? false,
97   skins2Support ? !onlyLibVLC,
98   waylandSupport ? true,
99   withQt5 ? true,
102 # chromecastSupport requires TCP port 8010 to be open for it to work.
103 # If your firewall is enabled, make sure to have something like:
104 #   networking.firewall.allowedTCPPorts = [ 8010 ];
107   inherit (lib) optionalString optionals;
109 stdenv.mkDerivation (finalAttrs: {
110   pname = "${optionalString onlyLibVLC "lib"}vlc";
111   version = "3.0.21";
113   src = fetchurl {
114     url = "https://get.videolan.org/vlc/${finalAttrs.version}/vlc-${finalAttrs.version}.tar.xz";
115     hash = "sha256-JNu+HX367qCZTV3vC73iABdzRxNtv+Vz9bakzuJa+7A=";
116   };
118   nativeBuildInputs =
119     [
120       autoreconfHook
121       lua5
122       perl
123       pkg-config
124       removeReferencesTo
125       unzip
126       wrapGAppsHook3
127     ]
128     ++ optionals chromecastSupport [ protobuf ]
129     ++ optionals withQt5 [ libsForQt5.wrapQtAppsHook ]
130     ++ optionals waylandSupport [
131       wayland-scanner
132     ];
134   # VLC uses a *ton* of libraries for various pieces of functionality, many of
135   # which are not included here for no other reason that nobody has mentioned
136   # needing them
137   buildInputs =
138     [
139       SDL
140       SDL_image
141       a52dec
142       alsa-lib
143       avahi
144       dbus
145       faad2
146       ffmpeg_4
147       flac
148       fluidsynth
149       fribidi
150       gnutls
151       libSM
152       libXpm
153       libXv
154       libXvMC
155       libarchive
156       libass
157       libbluray
158       libcaca
159       libcddb
160       libdc1394
161       libdvbpsi
162       libdvdnav
163       libdvdnav.libdvdread
164       libebml
165       libgcrypt
166       libgpg-error
167       libkate
168       libmad
169       libmatroska
170       libmodplug
171       libmtp
172       liboggz
173       libopus
174       libplacebo_5
175       libpulseaudio
176       libraw1394
177       librsvg
178       libsamplerate
179       libspatialaudio
180       libssh2
181       libtheora
182       libtiger
183       libupnp
184       libv4l
185       libva
186       libvdpau
187       libvorbis
188       libxml2
189       lua5
190       mpeg2dec
191       ncurses
192       samba
193       schroedinger
194       speex
195       srt
196       systemd
197       taglib
198       xcbutilkeysyms
199       wayland-scanner # only required for configure script
200       zlib
201     ]
202     ++ optionals (!stdenv.hostPlatform.isAarch && !onlyLibVLC) [ live555 ]
203     ++ optionals jackSupport [ libjack2 ]
204     ++ optionals chromecastSupport [
205       libmicrodns
206       protobuf
207     ]
208     ++ optionals skins2Support [
209       freetype
210       libXext
211       libXinerama
212       libXpm
213     ]
214     ++ optionals waylandSupport [
215       wayland
216       wayland-protocols
217     ]
218     ++ optionals withQt5 (
219       with libsForQt5;
220       [
221         qtbase
222         qtsvg
223         qtx11extras
224       ]
225     )
226     ++ optionals (waylandSupport && withQt5) [ libsForQt5.qtwayland ];
227   strictDeps = true;
229   env =
230     {
231       # vlc depends on a c11-gcc wrapper script which we don't have so we need to
232       # set the path to the compiler
233       BUILDCC = "${pkgsBuildBuild.stdenv.cc}/bin/gcc";
234       PKG_CONFIG_WAYLAND_SCANNER_WAYLAND_SCANNER = "wayland-scanner";
235     }
236     // lib.optionalAttrs stdenv.cc.isGNU {
237       NIX_CFLAGS_COMPILE = "-Wno-error=incompatible-pointer-types";
238     }
239     // lib.optionalAttrs (!stdenv.hostPlatform.isAarch) {
240       LIVE555_PREFIX = live555;
241     };
243   patches = [
244     # patch to build with recent live555
245     # upstream issue: https://code.videolan.org/videolan/vlc/-/issues/25473
246     (fetchpatch {
247       url = "https://code.videolan.org/videolan/vlc/uploads/eb1c313d2d499b8a777314f789794f9d/0001-Add-lssl-and-lcrypto-to-liblive555_plugin_la_LIBADD.patch";
248       hash = "sha256-qs3gY1ksCZlf931TSZyMuT2JD0sqrmcRCZwL+wVG0U8=";
249     })
250   ];
252   postPatch =
253     ''
254       substituteInPlace modules/text_renderer/freetype/platform_fonts.h \
255         --replace \
256           /usr/share/fonts/truetype/freefont \
257           ${freefont_ttf}/share/fonts/truetype
258     ''
259     # Upstream luac can't cross compile, so we have to install the lua sources
260     # instead of bytecode, which was built for buildPlatform:
261     # https://www.lua.org/wshop13/Jericke.pdf#page=39
262     + lib.optionalString (!stdenv.hostPlatform.canExecute stdenv.buildPlatform) ''
263       substituteInPlace share/Makefile.am \
264         --replace $'.luac \\\n' $'.lua \\\n'
265     '';
267   enableParallelBuilding = true;
269   dontWrapGApps = true; # to prevent double wrapping of Qtwrap and Gwrap
271   # Most of the libraries are auto-detected so we don't need to set a bunch of
272   # "--enable-foo" flags here
273   configureFlags =
274     [
275       "--enable-srt" # Explicit enable srt to ensure the patch is applied.
276       "--with-kde-solid=$out/share/apps/solid/actions"
277     ]
278     ++ optionals onlyLibVLC [ "--disable-vlc" ]
279     ++ optionals skins2Support [ "--enable-skins2" ]
280     ++ optionals waylandSupport [ "--enable-wayland" ]
281     ++ optionals chromecastSupport [
282       "--enable-sout"
283       "--enable-chromecast"
284       "--enable-microdns"
285     ];
287   # Remove runtime dependencies on libraries
288   postConfigure = ''
289     sed -i 's|^#define CONFIGURE_LINE.*$|#define CONFIGURE_LINE "<removed>"|g' config.h
290   '';
292   # fails on high core machines
293   # ld: cannot find -lvlc_vdpau: No such file or directory
294   # https://code.videolan.org/videolan/vlc/-/issues/27338
295   enableParallelInstalling = false;
297   # Add missing SOFA files
298   # Given in EXTRA_DIST, but not in install-data target
299   postInstall = ''
300     cp -R share/hrtfs $out/share/vlc
301   '';
303   preFixup = ''
304     qtWrapperArgs+=("''${gappsWrapperArgs[@]}")
305   '';
307   # - Touch plugins (plugins cache keyed off mtime and file size:
308   #     https://github.com/NixOS/nixpkgs/pull/35124#issuecomment-370552830
309   # - Remove references to the Qt development headers (used in error messages)
310   #
311   # pkgsBuildBuild is used here because buildPackages.libvlc somehow
312   # depends on a qt5.qttranslations that doesn't build, even though it
313   # should be the same as pkgsBuildBuild.qt5.qttranslations.
314   postFixup =
315     ''
316       find $out/lib/vlc/plugins -exec touch -d @1 '{}' ';'
317       ${
318         if stdenv.buildPlatform.canExecute stdenv.hostPlatform then "$out" else pkgsBuildBuild.libvlc
319       }/lib/vlc/vlc-cache-gen $out/vlc/plugins
320     ''
321     + optionalString withQt5 ''
322       remove-references-to -t "${libsForQt5.qtbase.dev}" $out/lib/vlc/plugins/gui/libqt_plugin.so
323     '';
325   passthru.updateScript = genericUpdater {
326     versionLister = writeShellScript "vlc-versionLister" ''
327       ${curl}/bin/curl -s https://get.videolan.org/vlc/ | sed -En 's/^.*href="([0-9]+(\.[0-9]+)+)\/".*$/\1/p'
328     '';
329   };
331   meta = {
332     description = "Cross-platform media player and streaming server";
333     homepage = "https://www.videolan.org/vlc/";
334     license = lib.licenses.lgpl21Plus;
335     maintainers = with lib.maintainers; [ alois31 ];
336     platforms = lib.platforms.linux;
337     mainProgram = "vlc";
338   };