nixpkgs/pkgs/applications/video/kodi/unwrapped.nix

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

260 lines
9.2 KiB
Nix
Raw Normal View History

2021-03-05 02:53:10 +01:00
{ stdenv, lib, fetchFromGitHub, autoconf, automake, libtool, makeWrapper
, pkg-config, cmake, yasm, python3Packages
, libgcrypt, libgpg-error, libunistring
2021-02-21 06:44:12 +01:00
, boost, avahi, lame
, gettext, pcre-cpp, yajl, fribidi, which
, openssl, gperf, tinyxml2, taglib, libssh, swig, jre_headless
2020-12-03 03:01:18 +01:00
, gtest, ncurses, spdlog
, libxml2, systemd
, alsa-lib, libGLU, libGL, fontconfig, freetype, ftgl
, libjpeg, libpng, libtiff
, libmpeg2, libsamplerate, libmad
, libogg, libvorbis, flac, libxslt
2022-01-08 09:03:11 +01:00
, lzo, libcdio, libmodplug, libass, libbluray, libudfread
, sqlite, libmysqlclient, nasm, gnutls, libva, libdrm
, curl, bzip2, zip, unzip, glxinfo
2016-02-21 15:31:41 +01:00
, libcec, libcec_platform, dcadec, libuuid
, libcrossguid, libmicrohttpd
, bluez, doxygen, giflib, glib, harfbuzz, lcms2, libidn, libpthreadstubs, libtasn1
, libplist, p11-kit, zlib, flatbuffers, fstrcmp, rapidjson
, lirc
, x11Support ? true, libX11, xorgproto, libXt, libXmu, libXext, libXinerama, libXrandr, libXtst, libXfixes, xdpyinfo, libXdmcp
, dbusSupport ? true, dbus
, joystickSupport ? true, cwiid
, nfsSupport ? true, libnfs
, pulseSupport ? true, libpulseaudio
, rtmpSupport ? true, rtmpdump
, sambaSupport ? true, samba
, udevSupport ? true, udev
, usbSupport ? false, libusb-compat-0_1
, vdpauSupport ? true, libvdpau
, waylandSupport ? false, wayland, wayland-protocols
, waylandpp ? null, libxkbcommon
, gbmSupport ? false, mesa, libinput
, buildPackages
}:
assert usbSupport -> !udevSupport; # libusb-compat-0_1 won't be used if udev is avaliable
assert gbmSupport || waylandSupport || x11Support;
let
2022-03-10 02:34:14 +01:00
kodiReleaseDate = "20220303";
kodiVersion = "19.4";
2020-12-03 03:01:18 +01:00
rel = "Matrix";
kodi_src = fetchFromGitHub {
owner = "xbmc";
repo = "xbmc";
rev = "${kodiVersion}-${rel}";
2022-03-10 02:34:14 +01:00
sha256 = "sha256-XDtmY3KthiD91kvueQRSamBcdM7fBpRntmZX6KRsCzE=";
2019-07-06 03:10:56 +02:00
};
2021-03-05 02:53:10 +01:00
ffmpeg = stdenv.mkDerivation rec {
pname = "kodi-ffmpeg";
2022-03-10 02:34:14 +01:00
version = "4.3.2"; # see https://github.com/xbmc/xbmc/blob/${kodiVersion}-${rel}/tools/depends/target/ffmpeg/FFMPEG-VERSION
2021-03-05 02:53:10 +01:00
src = fetchFromGitHub {
owner = "xbmc";
repo = "FFmpeg";
2022-03-10 02:34:14 +01:00
rev = "${version}-${rel}-19.2";
2021-10-09 01:18:23 +02:00
sha256 = "14s215sgc93ds1mrdbkgb7fvy94lpgv2ldricyxzis0gbzqfgs4f";
2021-03-05 02:53:10 +01:00
};
preConfigure = ''
cp ${kodi_src}/tools/depends/target/ffmpeg/{CMakeLists.txt,*.cmake} .
sed -i 's/ --cpu=''${CPU}//' CMakeLists.txt
sed -i 's/--strip=''${CMAKE_STRIP}/--strip=''${CMAKE_STRIP} --ranlib=''${CMAKE_RANLIB}/' CMakeLists.txt
'';
cmakeFlags = lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
"-DCROSSCOMPILING=ON"
"-DCPU=${stdenv.hostPlatform.parsed.cpu.name}"
"-DOS=${stdenv.hostPlatform.parsed.kernel.name}"
"-DPKG_CONFIG_EXECUTABLE=pkg-config"
];
buildInputs = [ libidn libtasn1 p11-kit zlib libva ]
++ lib.optional vdpauSupport libvdpau;
nativeBuildInputs = [ cmake nasm pkg-config gnutls ];
};
2019-07-06 03:10:56 +02:00
# We can build these externally but FindLibDvd.cmake forces us to build it
# them, so we currently just use them for the src.
2021-03-05 02:53:10 +01:00
libdvdcss = fetchFromGitHub {
owner = "xbmc";
repo = "libdvdcss";
rev = "1.4.2-Leia-Beta-5";
2021-03-05 02:53:10 +01:00
sha256 = "0j41ydzx0imaix069s3z07xqw9q95k7llh06fc27dcn6f7b8ydyl";
};
2021-03-05 02:53:10 +01:00
libdvdnav = fetchFromGitHub {
owner = "xbmc";
repo = "libdvdnav";
rev = "6.0.0-Leia-Alpha-3";
2021-03-05 02:53:10 +01:00
sha256 = "0qwlf4lgahxqxk1r2pzl866mi03pbp7l1fc0rk522sc0ak2s9jhb";
};
2021-03-05 02:53:10 +01:00
libdvdread = fetchFromGitHub {
owner = "xbmc";
repo = "libdvdread";
rev = "6.0.0-Leia-Alpha-3";
2021-03-05 02:53:10 +01:00
sha256 = "1xxn01mhkdnp10cqdr357wx77vyzfb5glqpqyg8m0skyi75aii59";
};
kodi_platforms = lib.optional gbmSupport "gbm"
++ lib.optional waylandSupport "wayland"
++ lib.optional x11Support "x11";
2020-12-03 03:01:18 +01:00
2019-08-13 23:52:01 +02:00
in stdenv.mkDerivation {
pname = "kodi";
version = kodiVersion;
src = kodi_src;
# This is a backport of
# https://github.com/xbmc/xbmc/commit/a6dedce7ba1f03bdd83b019941d1e369a06f7888
# to Kodi 19.4 Matrix.
# This can be removed once a new release of Kodi comes out and we upgrade
# to it.
patches = [
./add-KODI_WEBSERVER_EXTRA_WHITELIST.patch
];
buildInputs = [
gnutls libidn libtasn1 nasm p11-kit
2020-12-03 03:01:18 +01:00
libxml2 python3Packages.python
2017-05-24 10:03:17 +02:00
boost libmicrohttpd
2018-03-25 23:33:23 +02:00
gettext pcre-cpp yajl fribidi libva libdrm
openssl gperf tinyxml2 taglib libssh
2020-12-03 03:01:18 +01:00
gtest ncurses spdlog
alsa-lib libGL libGLU fontconfig freetype ftgl
libjpeg libpng libtiff
libmpeg2 libsamplerate libmad
libogg libvorbis flac libxslt systemd
2022-01-08 09:03:11 +01:00
lzo libcdio libmodplug libass libbluray libudfread
sqlite libmysqlclient avahi lame
curl bzip2 zip unzip glxinfo
2016-02-21 15:31:41 +01:00
libcec libcec_platform dcadec libuuid
libgcrypt libgpg-error libunistring
libcrossguid libplist
bluez giflib glib harfbuzz lcms2 libpthreadstubs
ffmpeg flatbuffers fstrcmp rapidjson
lirc
2021-04-09 13:26:18 +02:00
mesa # for libEGL
]
++ lib.optional x11Support [
2020-05-16 15:52:20 +02:00
libX11 xorgproto libXt libXmu libXext.dev libXdmcp
libXinerama libXrandr.dev libXtst libXfixes
]
++ lib.optional dbusSupport dbus
++ lib.optional joystickSupport cwiid
++ lib.optional nfsSupport libnfs
++ lib.optional pulseSupport libpulseaudio
++ lib.optional rtmpSupport rtmpdump
++ lib.optional sambaSupport samba
++ lib.optional udevSupport udev
2020-04-28 05:29:39 +02:00
++ lib.optional usbSupport libusb-compat-0_1
2019-04-11 20:06:06 +02:00
++ lib.optional vdpauSupport libvdpau
++ lib.optionals waylandSupport [
2020-08-08 08:27:47 +02:00
wayland
waylandpp.dev
2020-04-22 17:20:20 +02:00
wayland-protocols
2019-04-11 20:06:06 +02:00
# Not sure why ".dev" is needed here, but CMake doesn't find libxkbcommon otherwise
libxkbcommon.dev
2019-12-15 16:05:57 +01:00
]
++ lib.optional gbmSupport [
2019-12-15 16:05:57 +01:00
libxkbcommon.dev
mesa.dev
libinput.dev
2019-04-11 20:06:06 +02:00
];
2016-02-29 08:31:58 +01:00
2017-05-24 10:03:17 +02:00
nativeBuildInputs = [
cmake
doxygen
makeWrapper
which
pkg-config
2019-07-06 03:10:56 +02:00
autoconf automake libtool # still needed for some components. Check if that is the case with 19.0
2020-12-03 03:01:18 +01:00
jre_headless yasm gettext python3Packages.python flatbuffers
# for TexturePacker
giflib zlib libpng libjpeg lzo
] ++ lib.optionals waylandSupport [ wayland-protocols waylandpp.bin ];
depsBuildBuild = [
buildPackages.stdenv.cc
];
cmakeFlags = [
"-DAPP_RENDER_SYSTEM=${if gbmSupport then "gles" else "gl"}"
2021-03-05 02:53:10 +01:00
"-Dlibdvdcss_URL=${libdvdcss}"
"-Dlibdvdnav_URL=${libdvdnav}"
"-Dlibdvdread_URL=${libdvdread}"
"-DGIT_VERSION=${kodiReleaseDate}"
"-DENABLE_EVENTCLIENTS=ON"
"-DENABLE_INTERNAL_CROSSGUID=OFF"
"-DENABLE_OPTICAL=ON"
"-DLIRC_DEVICE=/run/lirc/lircd"
"-DSWIG_EXECUTABLE=${buildPackages.swig}/bin/swig"
"-DFLATBUFFERS_FLATC_EXECUTABLE=${buildPackages.flatbuffers}/bin/flatc"
2020-12-03 03:01:18 +01:00
"-DPYTHON_EXECUTABLE=${buildPackages.python3Packages.python}/bin/python"
# When wrapped KODI_HOME will likely contain symlinks to static assets
# that Kodi's built in webserver will cautiously refuse to serve up
# (because their realpaths are outside of KODI_HOME and the other
# whitelisted directories). This adds the entire nix store to the Kodi
# webserver whitelist to avoid this problem.
"-DKODI_WEBSERVER_EXTRA_WHITELIST=${builtins.storeDir}"
] ++ lib.optional waylandSupport [
"-DWAYLANDPP_SCANNER=${buildPackages.waylandpp}/bin/wayland-scanner++"
];
# 14 tests fail but the biggest issue is that every test takes 30 seconds -
# I'm guessing there is a thing waiting to time out
doCheck = false;
2021-03-03 02:23:37 +01:00
preConfigure = ''
cmakeFlagsArray+=("-DCORE_PLATFORM_NAME=${lib.concatStringsSep " " kodi_platforms}")
'' + lib.optionalString (stdenv.hostPlatform != stdenv.buildPlatform) ''
# Need these tools on the build system when cross compiling,
# hacky, but have found no other way.
2021-11-07 22:08:13 +01:00
CXX=$CXX_FOR_BUILD LD=ld make -C tools/depends/native/JsonSchemaBuilder
cmakeFlags+=" -DWITH_JSONSCHEMABUILDER=$PWD/tools/depends/native/JsonSchemaBuilder/bin"
2021-11-07 22:08:13 +01:00
CXX=$CXX_FOR_BUILD LD=ld make EXTRA_CONFIGURE= -C tools/depends/native/TexturePacker
cmakeFlags+=" -DWITH_TEXTUREPACKER=$PWD/tools/depends/native/TexturePacker/bin"
'';
postPatch = ''
2020-12-03 03:01:18 +01:00
substituteInPlace xbmc/platform/posix/PosixTimezone.cpp \
--replace 'usr/share/zoneinfo' 'etc/zoneinfo'
'';
postInstall = ''
for p in $(ls $out/bin/) ; do
wrapProgram $out/bin/$p \
--prefix PATH ":" "${lib.makeBinPath ([ python3Packages.python glxinfo ]
++ lib.optional x11Support xdpyinfo ++ lib.optional sambaSupport samba)}" \
--prefix LD_LIBRARY_PATH ":" "${lib.makeLibraryPath
([ curl systemd libmad libvdpau libcec libcec_platform libass ]
++ lib.optional nfsSupport libnfs
++ lib.optional rtmpSupport rtmpdump)}"
done
substituteInPlace $out/share/xsessions/kodi.desktop \
--replace kodi-standalone $out/bin/kodi-standalone
'';
doInstallCheck = true;
installCheckPhase = "$out/bin/kodi --version";
2018-09-06 21:40:18 +02:00
passthru = {
2020-12-03 03:01:18 +01:00
pythonPackages = python3Packages;
ffmpeg = ffmpeg;
2018-09-06 21:40:18 +02:00
};
meta = with lib; {
description = "Media center";
homepage = "https://kodi.tv/";
license = licenses.gpl2Plus;
platforms = platforms.linux;
2021-03-19 00:52:44 +01:00
maintainers = teams.kodi.members;
};
}