python3Packages.orjson: Disable failing tests on 32 bit
[NixPkgs.git] / pkgs / applications / video / kodi / unwrapped.nix
blob6eadd06af0fb195d4815c3145e2755ee9334c719
1 { stdenv, lib, fetchFromGitHub, autoconf, automake, libtool, makeWrapper
2 , pkg-config, cmake, yasm, python3Packages
3 , libxcrypt, libgcrypt, libgpg-error, libunistring
4 , boost, avahi, lame
5 , gettext, pcre-cpp, yajl, fribidi, which
6 , openssl, gperf, tinyxml2, taglib, libssh, swig, jre_headless
7 , gtest, ncurses, spdlog
8 , libxml2, systemd
9 , alsa-lib, libGLU, libGL, fontconfig, freetype, ftgl
10 , libjpeg, libpng, libtiff
11 , libmpeg2, libsamplerate, libmad
12 , libogg, libvorbis, flac, libxslt
13 , lzo, libcdio, libmodplug, libass, libbluray, libudfread
14 , sqlite, libmysqlclient, nasm, gnutls, libva, libdrm
15 , curl, bzip2, zip, unzip, glxinfo
16 , libcec, libcec_platform, dcadec, libuuid
17 , libcrossguid, libmicrohttpd
18 , bluez, doxygen, giflib, glib, harfbuzz, lcms2, libidn, libpthreadstubs, libtasn1
19 , libplist, p11-kit, zlib, flatbuffers, fstrcmp, rapidjson
20 , lirc
21 , x11Support ? true, libX11, xorgproto, libXt, libXmu, libXext, libXinerama, libXrandr, libXtst, libXfixes, xdpyinfo, libXdmcp
22 , dbusSupport ? true, dbus
23 , joystickSupport ? true, cwiid
24 , nfsSupport ? true, libnfs
25 , pulseSupport ? true, libpulseaudio
26 , rtmpSupport ? true, rtmpdump
27 , sambaSupport ? true, samba
28 , udevSupport ? true, udev
29 , usbSupport  ? false, libusb-compat-0_1
30 , vdpauSupport ? true, libvdpau
31 , waylandSupport ? false, wayland, wayland-protocols
32 , waylandpp ?  null, libxkbcommon
33 , gbmSupport ? false, mesa, libinput
34 , buildPackages
37 assert usbSupport -> !udevSupport; # libusb-compat-0_1 won't be used if udev is avaliable
38 assert gbmSupport || waylandSupport || x11Support;
40 let
41   kodiReleaseDate = "20220303";
42   kodiVersion = "19.4";
43   rel = "Matrix";
45   kodi_src = fetchFromGitHub {
46     owner  = "xbmc";
47     repo   = "xbmc";
48     rev    = "${kodiVersion}-${rel}";
49     sha256 = "sha256-XDtmY3KthiD91kvueQRSamBcdM7fBpRntmZX6KRsCzE=";
50   };
52   ffmpeg = stdenv.mkDerivation rec {
53     pname = "kodi-ffmpeg";
54     version = "4.3.2"; # see https://github.com/xbmc/xbmc/blob/${kodiVersion}-${rel}/tools/depends/target/ffmpeg/FFMPEG-VERSION
55     src = fetchFromGitHub {
56       owner   = "xbmc";
57       repo    = "FFmpeg";
58       rev     = "${version}-${rel}-19.2";
59       sha256  = "14s215sgc93ds1mrdbkgb7fvy94lpgv2ldricyxzis0gbzqfgs4f";
60     };
61     preConfigure = ''
62       cp ${kodi_src}/tools/depends/target/ffmpeg/{CMakeLists.txt,*.cmake} .
63       sed -i 's/ --cpu=''${CPU}//' CMakeLists.txt
64       sed -i 's/--strip=''${CMAKE_STRIP}/--strip=''${CMAKE_STRIP} --ranlib=''${CMAKE_RANLIB}/' CMakeLists.txt
65     '';
66     cmakeFlags = lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
67       "-DCROSSCOMPILING=ON"
68       "-DCPU=${stdenv.hostPlatform.parsed.cpu.name}"
69       "-DOS=${stdenv.hostPlatform.parsed.kernel.name}"
70       "-DPKG_CONFIG_EXECUTABLE=pkg-config"
71     ];
72     buildInputs = [ libidn libtasn1 p11-kit zlib libva ]
73       ++ lib.optional vdpauSupport libvdpau;
74     nativeBuildInputs = [ cmake nasm pkg-config gnutls ];
75   };
77   # We can build these externally but FindLibDvd.cmake forces us to build it
78   # them, so we currently just use them for the src.
79   libdvdcss = fetchFromGitHub {
80     owner = "xbmc";
81     repo = "libdvdcss";
82     rev = "1.4.2-Leia-Beta-5";
83     sha256 = "0j41ydzx0imaix069s3z07xqw9q95k7llh06fc27dcn6f7b8ydyl";
84   };
86   libdvdnav = fetchFromGitHub {
87     owner = "xbmc";
88     repo = "libdvdnav";
89     rev = "6.0.0-Leia-Alpha-3";
90     sha256 = "0qwlf4lgahxqxk1r2pzl866mi03pbp7l1fc0rk522sc0ak2s9jhb";
91   };
93   libdvdread = fetchFromGitHub {
94     owner = "xbmc";
95     repo = "libdvdread";
96     rev = "6.0.0-Leia-Alpha-3";
97     sha256 = "1xxn01mhkdnp10cqdr357wx77vyzfb5glqpqyg8m0skyi75aii59";
98   };
100   kodi_platforms = lib.optional gbmSupport "gbm"
101     ++ lib.optional waylandSupport "wayland"
102     ++ lib.optional x11Support "x11";
104 in stdenv.mkDerivation {
105     pname = "kodi";
106     version = kodiVersion;
108     src = kodi_src;
110     # This is a backport of
111     # https://github.com/xbmc/xbmc/commit/a6dedce7ba1f03bdd83b019941d1e369a06f7888
112     # to Kodi 19.4 Matrix.
113     # This can be removed once a new release of Kodi comes out and we upgrade
114     # to it.
115     patches = [
116       ./add-KODI_WEBSERVER_EXTRA_WHITELIST.patch
117     ];
119     buildInputs = [
120       gnutls libidn libtasn1 nasm p11-kit
121       libxml2 python3Packages.python
122       boost libmicrohttpd
123       gettext pcre-cpp yajl fribidi libva libdrm
124       openssl gperf tinyxml2 taglib libssh
125       gtest ncurses spdlog
126       alsa-lib libGL libGLU fontconfig freetype ftgl
127       libjpeg libpng libtiff
128       libmpeg2 libsamplerate libmad
129       libogg libvorbis flac libxslt systemd
130       lzo libcdio libmodplug libass libbluray libudfread
131       sqlite libmysqlclient avahi lame
132       curl bzip2 zip unzip glxinfo
133       libcec libcec_platform dcadec libuuid
134       libxcrypt libgcrypt libgpg-error libunistring
135       libcrossguid libplist
136       bluez giflib glib harfbuzz lcms2 libpthreadstubs
137       ffmpeg flatbuffers fstrcmp rapidjson
138       lirc
139       mesa # for libEGL
140     ]
141     ++ lib.optionals x11Support [
142       libX11 xorgproto libXt libXmu libXext.dev libXdmcp
143       libXinerama libXrandr.dev libXtst libXfixes
144     ]
145     ++ lib.optional  dbusSupport     dbus
146     ++ lib.optional  joystickSupport cwiid
147     ++ lib.optional  nfsSupport      libnfs
148     ++ lib.optional  pulseSupport    libpulseaudio
149     ++ lib.optional  rtmpSupport     rtmpdump
150     ++ lib.optional  sambaSupport    samba
151     ++ lib.optional  udevSupport     udev
152     ++ lib.optional  usbSupport      libusb-compat-0_1
153     ++ lib.optional  vdpauSupport    libvdpau
154     ++ lib.optionals waylandSupport [
155       wayland
156       waylandpp.dev
157       wayland-protocols
158       # Not sure why ".dev" is needed here, but CMake doesn't find libxkbcommon otherwise
159       libxkbcommon.dev
160     ]
161     ++ lib.optionals gbmSupport [
162       libxkbcommon.dev
163       mesa.dev
164       libinput.dev
165     ];
167     nativeBuildInputs = [
168       cmake
169       doxygen
170       makeWrapper
171       which
172       pkg-config
173       autoconf automake libtool # still needed for some components. Check if that is the case with 19.0
174       jre_headless yasm gettext python3Packages.python flatbuffers
176       # for TexturePacker
177       giflib zlib libpng libjpeg lzo
178     ] ++ lib.optionals waylandSupport [ wayland-protocols waylandpp.bin ];
180     depsBuildBuild = [
181       buildPackages.stdenv.cc
182     ];
184     cmakeFlags = [
185       "-DAPP_RENDER_SYSTEM=${if gbmSupport then "gles" else "gl"}"
186       "-Dlibdvdcss_URL=${libdvdcss}"
187       "-Dlibdvdnav_URL=${libdvdnav}"
188       "-Dlibdvdread_URL=${libdvdread}"
189       "-DGIT_VERSION=${kodiReleaseDate}"
190       "-DENABLE_EVENTCLIENTS=ON"
191       "-DENABLE_INTERNAL_CROSSGUID=OFF"
192       "-DENABLE_OPTICAL=ON"
193       "-DLIRC_DEVICE=/run/lirc/lircd"
194       "-DSWIG_EXECUTABLE=${buildPackages.swig}/bin/swig"
195       "-DFLATBUFFERS_FLATC_EXECUTABLE=${buildPackages.flatbuffers}/bin/flatc"
196       "-DPYTHON_EXECUTABLE=${buildPackages.python3Packages.python}/bin/python"
197       # When wrapped KODI_HOME will likely contain symlinks to static assets
198       # that Kodi's built in webserver will cautiously refuse to serve up
199       # (because their realpaths are outside of KODI_HOME and the other
200       # whitelisted directories). This adds the entire nix store to the Kodi
201       # webserver whitelist to avoid this problem.
202       "-DKODI_WEBSERVER_EXTRA_WHITELIST=${builtins.storeDir}"
203     ] ++ lib.optionals waylandSupport [
204       "-DWAYLANDPP_SCANNER=${buildPackages.waylandpp}/bin/wayland-scanner++"
205     ];
207     # 14 tests fail but the biggest issue is that every test takes 30 seconds -
208     # I'm guessing there is a thing waiting to time out
209     doCheck = false;
211     preConfigure = ''
212       cmakeFlagsArray+=("-DCORE_PLATFORM_NAME=${lib.concatStringsSep " " kodi_platforms}")
213     '' + lib.optionalString (stdenv.hostPlatform != stdenv.buildPlatform) ''
214       # Need these tools on the build system when cross compiling,
215       # hacky, but have found no other way.
216       CXX=$CXX_FOR_BUILD LD=ld make -C tools/depends/native/JsonSchemaBuilder
217       cmakeFlags+=" -DWITH_JSONSCHEMABUILDER=$PWD/tools/depends/native/JsonSchemaBuilder/bin"
219       CXX=$CXX_FOR_BUILD LD=ld make EXTRA_CONFIGURE= -C tools/depends/native/TexturePacker
220       cmakeFlags+=" -DWITH_TEXTUREPACKER=$PWD/tools/depends/native/TexturePacker/bin"
221     '';
223     postPatch = ''
224       substituteInPlace xbmc/platform/posix/PosixTimezone.cpp \
225         --replace 'usr/share/zoneinfo' 'etc/zoneinfo'
226     '';
228     postInstall = ''
229       for p in $(ls $out/bin/) ; do
230         wrapProgram $out/bin/$p \
231           --prefix PATH ":" "${lib.makeBinPath ([ python3Packages.python glxinfo ]
232             ++ lib.optional x11Support xdpyinfo ++ lib.optional sambaSupport samba)}" \
233           --prefix LD_LIBRARY_PATH ":" "${lib.makeLibraryPath
234               ([ curl systemd libmad libvdpau libcec libcec_platform libass ]
235                  ++ lib.optional nfsSupport libnfs
236                  ++ lib.optional rtmpSupport rtmpdump)}"
237       done
239       substituteInPlace $out/share/xsessions/kodi.desktop \
240         --replace kodi-standalone $out/bin/kodi-standalone
241     '';
243     doInstallCheck = true;
245     installCheckPhase = "$out/bin/kodi --version";
247     passthru = {
248       pythonPackages = python3Packages;
249       ffmpeg = ffmpeg;
250     };
252     meta = with lib; {
253       description = "Media center";
254       homepage    = "https://kodi.tv/";
255       license     = licenses.gpl2Plus;
256       platforms   = platforms.linux;
257       maintainers = teams.kodi.members;
258     };