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.
94 chromecastSupport ? true,
97 skins2Support ? !onlyLibVLC,
98 waylandSupport ? 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";
114 url = "https://get.videolan.org/vlc/${finalAttrs.version}/vlc-${finalAttrs.version}.tar.xz";
115 hash = "sha256-JNu+HX367qCZTV3vC73iABdzRxNtv+Vz9bakzuJa+7A=";
128 ++ optionals chromecastSupport [ protobuf ]
129 ++ optionals withQt5 [ libsForQt5.wrapQtAppsHook ]
130 ++ optionals waylandSupport [
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
199 wayland-scanner # only required for configure script
202 ++ optionals (!stdenv.hostPlatform.isAarch && !onlyLibVLC) [ live555 ]
203 ++ optionals jackSupport [ libjack2 ]
204 ++ optionals chromecastSupport [
208 ++ optionals skins2Support [
214 ++ optionals waylandSupport [
218 ++ optionals withQt5 (
226 ++ optionals (waylandSupport && withQt5) [ libsForQt5.qtwayland ];
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";
236 // lib.optionalAttrs stdenv.cc.isGNU {
237 NIX_CFLAGS_COMPILE = "-Wno-error=incompatible-pointer-types";
239 // lib.optionalAttrs (!stdenv.hostPlatform.isAarch) {
240 LIVE555_PREFIX = live555;
244 # patch to build with recent live555
245 # upstream issue: https://code.videolan.org/videolan/vlc/-/issues/25473
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=";
254 substituteInPlace modules/text_renderer/freetype/platform_fonts.h \
256 /usr/share/fonts/truetype/freefont \
257 ${freefont_ttf}/share/fonts/truetype
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'
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
275 "--enable-srt" # Explicit enable srt to ensure the patch is applied.
276 "--with-kde-solid=$out/share/apps/solid/actions"
278 ++ optionals onlyLibVLC [ "--disable-vlc" ]
279 ++ optionals skins2Support [ "--enable-skins2" ]
280 ++ optionals waylandSupport [ "--enable-wayland" ]
281 ++ optionals chromecastSupport [
283 "--enable-chromecast"
287 # Remove runtime dependencies on libraries
289 sed -i 's|^#define CONFIGURE_LINE.*$|#define CONFIGURE_LINE "<removed>"|g' config.h
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
300 cp -R share/hrtfs $out/share/vlc
304 qtWrapperArgs+=("''${gappsWrapperArgs[@]}")
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)
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.
316 find $out/lib/vlc/plugins -exec touch -d @1 '{}' ';'
318 if stdenv.buildPlatform.canExecute stdenv.hostPlatform then "$out" else pkgsBuildBuild.libvlc
319 }/lib/vlc/vlc-cache-gen $out/vlc/plugins
321 + optionalString withQt5 ''
322 remove-references-to -t "${libsForQt5.qtbase.dev}" $out/lib/vlc/plugins/gui/libqt_plugin.so
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'
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;