nixpkgs/pkgs/applications/video/vlc/default.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

302 lines
6.9 KiB
Nix
Raw Normal View History

{ lib
, stdenv
2023-09-14 08:31:35 +00:00
, pkgsBuildBuild
, fetchurl
, fetchpatch
, SDL
, SDL_image
, a52dec
, alsa-lib
, autoreconfHook
, avahi
, dbus
, faad2
2022-02-05 00:20:22 +00:00
, ffmpeg_4
, flac
, fluidsynth
, freefont_ttf
, freetype
, fribidi
, gnutls
, libSM
, libXext
, libXinerama
, libXpm
, libXv
, libXvMC
, libarchive
, libass
, libbluray
, libcaca
, libcddb
, libdc1394
, libdvbpsi
, libdvdnav
, libebml
, libgcrypt
, libgpg-error
, libjack2
, libkate
, libmad
, libmatroska
, libmicrodns
, libmodplug
, libmtp
, liboggz
, libopus
2022-06-25 17:43:56 +00:00
, libplacebo
, libpulseaudio
, libraw1394
, librsvg
, libsamplerate
, libspatialaudio
, libssh2
, libtheora
, libtiger
, libupnp
, libv4l
, libva
, libvdpau
, libvorbis
, libxml2
, live555
, lua5
, mpeg2dec
, ncurses
, perl
, pkg-config
, protobuf
, qtbase
, qtsvg
, qtwayland
, qtx11extras
, removeReferencesTo
, samba
, schroedinger
, speex
, srt
, systemd
, taglib
, unzip
, wayland
, wayland-protocols
, wrapGAppsHook
, wrapQtAppsHook
, xcbutilkeysyms
, zlib
, chromecastSupport ? true
, jackSupport ? false
, onlyLibVLC ? false
, skins2Support ? !onlyLibVLC
, waylandSupport ? true
, withQt5 ? true
}:
# chromecastSupport requires TCP port 8010 to be open for it to work.
# If your firewall is enabled, make sure to have something like:
# networking.firewall.allowedTCPPorts = [ 8010 ];
let
inherit (lib) optionalString optional optionals;
in
stdenv.mkDerivation (finalAttrs: {
pname = "${optionalString onlyLibVLC "lib"}vlc";
2022-12-02 06:55:10 +00:00
version = "3.0.18";
src = fetchurl {
url = "http://get.videolan.org/vlc/${finalAttrs.version}/vlc-${finalAttrs.version}.tar.xz";
hash = "sha256-VwlEOcNl2KqLm0H6MIDMDu8r7+YCW7XO9yKszGJa7ew=";
};
nativeBuildInputs = [
autoreconfHook
2023-09-14 08:31:35 +00:00
lua5
perl
pkg-config
removeReferencesTo
unzip
wrapGAppsHook
]
2023-09-14 08:31:35 +00:00
++ optional chromecastSupport protobuf
++ optionals withQt5 [ wrapQtAppsHook ]
++ optionals waylandSupport [
wayland
wayland-protocols
];
2018-04-16 09:34:07 +00:00
# VLC uses a *ton* of libraries for various pieces of functionality, many of
# which are not included here for no other reason that nobody has mentioned
# needing them
buildInputs = [
SDL
SDL_image
a52dec
alsa-lib
avahi
dbus
faad2
2022-02-05 00:20:22 +00:00
ffmpeg_4
flac
fluidsynth
fribidi
gnutls
libSM
libXpm
libXv
libXvMC
libarchive
libass
libbluray
2023-07-07 16:11:08 +00:00
libcaca
libcddb
libdc1394
libdvbpsi
libdvdnav
libdvdnav.libdvdread
libebml
libgcrypt
libgpg-error
libkate
libmad
libmatroska
libmodplug
libmtp
liboggz
libopus
2022-06-25 17:43:56 +00:00
libplacebo
libpulseaudio
libraw1394
librsvg
libsamplerate
libspatialaudio
libssh2
libtheora
libtiger
libupnp
libv4l
libva
libvdpau
libvorbis
libxml2
lua5
mpeg2dec
ncurses
samba
schroedinger
speex
srt
systemd
taglib
xcbutilkeysyms
zlib
]
++ optional (!stdenv.hostPlatform.isAarch && !onlyLibVLC) live555
++ optional jackSupport libjack2
++ optionals chromecastSupport [ libmicrodns protobuf ]
++ optionals skins2Support [
2022-01-22 00:37:57 +00:00
freetype
libXext
libXinerama
libXpm
]
2022-01-22 00:37:57 +00:00
++ optionals waylandSupport [ wayland wayland-protocols ]
++ optionals withQt5 [ qtbase qtsvg qtx11extras ]
++ optional (waylandSupport && withQt5) qtwayland;
env = {
# vlc depends on a c11-gcc wrapper script which we don't have so we need to
# set the path to the compiler
2023-09-14 08:31:35 +00:00
BUILDCC = "${pkgsBuildBuild.stdenv.cc}/bin/gcc";
PKG_CONFIG_WAYLAND_SCANNER_WAYLAND_SCANNER = "wayland-scanner";
} // lib.optionalAttrs (!stdenv.hostPlatform.isAarch) {
LIVE555_PREFIX = live555;
};
vlc: Fix build for Qt >= 5.7.0 This basically does something similar than the AUR build: https://aur.archlinux.org/packages/vlc-qt5/ On our side, all there is to do is to force compiling using C++11 mode and use a patch that the AUR package took from the following upstream patchwork URL: https://patches.videolan.org/patch/14061/ Instead of passing CXXFLAGS to the configure script, I'm using sed here to make sure we don't override flags figured out by configure. For example if ./configure is used with CXXFLAGS=-std=c++11 appended or prepended, we have something like: ... -I../include -std=c++11 -Wall -Wextra -Wsign-compare ... While if we don't do that at all, we have something like: ... -I../include -g -O2 -Wall -Wextra -Wsign-compare ... Another way would be to use NIX_CFLAGS_COMPILE, but that would affect even compilation of C code and thus resulting in a bunch of warnings like this: cc1: warning: command line option '-std=c++11' is valid for C++/ObjC++ but not for C So with our approach the flags during build look much better: ... -I../include -std=c++11 -g -O2 -Wall -Wextra -Wsign-compare ... Another thing I've changed is that the vlc_qt5 attribute in all-packages.nix now uses the latest Qt 5 version, because the build for Qt >= 5.7.0 is now no longer broken. I've also ordered the preConfigure attribute before the configureFlags attribute, because it makes more sense in terms of context (pre -> configure -> post). Tested by building on x86_64-linux with libsForQt56.vlc, libsForQt58.vlc and vlc (the Qt 4 version, just to be sure I didn't accidentally break it). Signed-off-by: aszlig <aszlig@redmoonstudios.org> Cc: @ttuegel
2017-04-19 01:28:08 +00:00
patches = [
2022-12-02 06:55:10 +00:00
# patch to build with recent live555
2022-01-20 08:47:24 +00:00
# upstream issue: https://code.videolan.org/videolan/vlc/-/issues/25473
(fetchpatch {
url = "https://code.videolan.org/videolan/vlc/uploads/eb1c313d2d499b8a777314f789794f9d/0001-Add-lssl-and-lcrypto-to-liblive555_plugin_la_LIBADD.patch";
sha256 = "0kyi8q2zn2ww148ngbia9c7qjgdrijf4jlvxyxgrj29cb5iy1kda";
})
2023-04-06 20:35:22 +00:00
# patch to build with recent libplacebo
# https://code.videolan.org/videolan/vlc/-/merge_requests/3027
2023-04-06 20:35:22 +00:00
(fetchpatch {
url = "https://code.videolan.org/videolan/vlc/-/commit/65ea8d19d91ac1599a29e8411485a72fe89c45e2.patch";
hash = "sha256-Zz+g75V6X9OZI3sn614K9Uenxl3WtRHKSdLkWP3b17w=";
2023-04-06 20:35:22 +00:00
})
];
2018-04-16 09:34:07 +00:00
postPatch = ''
substituteInPlace modules/text_renderer/freetype/platform_fonts.h --replace \
/usr/share/fonts/truetype/freefont ${freefont_ttf}/share/fonts/truetype
2023-09-14 08:31:35 +00:00
'' + lib.optionalString (!stdenv.hostPlatform.canExecute stdenv.buildPlatform) ''
# Upstream luac can't cross compile, so we have to install the lua
# sources, not bytecode:
# https://www.lua.org/wshop13/Jericke.pdf#page=39
substituteInPlace share/Makefile.am --replace $'.luac \\\n' $'.lua \\\n'
2018-04-16 09:34:07 +00:00
'';
enableParallelBuilding = true;
dontWrapGApps = true; # to prevent double wrapping of Qtwrap and Gwrap
preFixup = ''
qtWrapperArgs+=("''${gappsWrapperArgs[@]}")
'';
# - Touch plugins (plugins cache keyed off mtime and file size:
# https://github.com/NixOS/nixpkgs/pull/35124#issuecomment-370552830
# - Remove references to the Qt development headers (used in error messages)
2023-09-14 08:31:35 +00:00
#
# pkgsBuildBuild is used here because buildPackages.libvlc somehow
# depends on a qt5.qttranslations that doesn't build, even though it
# should be the same as pkgsBuildBuild.qt5.qttranslations.
2018-04-16 09:34:07 +00:00
postFixup = ''
find $out/lib/vlc/plugins -exec touch -d @1 '{}' ';'
2023-09-14 08:31:35 +00:00
${if stdenv.buildPlatform.canExecute stdenv.hostPlatform then "$out" else pkgsBuildBuild.libvlc}/lib/vlc/vlc-cache-gen $out/vlc/plugins
2018-11-17 10:16:36 +00:00
'' + optionalString withQt5 ''
remove-references-to -t "${qtbase.dev}" $out/lib/vlc/plugins/gui/libqt_plugin.so
'';
2018-04-16 09:34:07 +00:00
# Most of the libraries are auto-detected so we don't need to set a bunch of
# "--enable-foo" flags here
configureFlags = [
"--enable-srt" # Explicit enable srt to ensure the patch is applied.
"--with-kde-solid=$out/share/apps/solid/actions"
2022-01-22 00:37:57 +00:00
]
++ optional onlyLibVLC "--disable-vlc"
++ optional skins2Support "--enable-skins2"
++ optional waylandSupport "--enable-wayland"
++ optionals chromecastSupport [
"--enable-sout"
"--enable-chromecast"
"--enable-microdns"
];
2018-04-16 09:34:07 +00:00
# Remove runtime dependencies on libraries
postConfigure = ''
sed -i 's|^#define CONFIGURE_LINE.*$|#define CONFIGURE_LINE "<removed>"|g' config.h
'';
# fails on high core machines
# ld: cannot find -lvlc_vdpau: No such file or directory
# https://code.videolan.org/videolan/vlc/-/issues/27338
enableParallelInstalling = false;
# Add missing SOFA files
# Given in EXTRA_DIST, but not in install-data target
postInstall = ''
cp -R share/hrtfs $out/share/vlc
'';
meta = {
description = "Cross-platform media player and streaming server";
homepage = "http://www.videolan.org/vlc/";
license = lib.licenses.lgpl21Plus;
maintainers = with lib.maintainers; [ AndersonTorres ];
platforms = lib.platforms.linux;
};
})