biome: 1.9.2 -> 1.9.3
[NixPkgs.git] / pkgs / applications / video / kodi / unwrapped.nix
blob374837b01b38cc4669433a24bd6cee893b8e6462
1 { stdenv, lib, fetchFromGitHub, fetchzip
2 , autoconf, automake, libtool, makeWrapper
3 , pkg-config, cmake, yasm, python3Packages
4 , libxcrypt, libgcrypt, libgpg-error, libunistring
5 , boost, avahi, lame
6 , gettext, pcre-cpp, yajl, fribidi, which
7 , openssl, gperf, tinyxml2, tinyxml-2, taglib, libssh, jre_headless
8 , gtest, ncurses, spdlog
9 , libxml2, systemd
10 , alsa-lib, libGLU, libGL, ffmpeg, fontconfig, freetype, ftgl
11 , libjpeg, libpng, libtiff
12 , libmpeg2, libsamplerate, libmad
13 , libogg, libvorbis, flac, libxslt
14 , lzo, libcdio, libmodplug, libass, libbluray, libudfread
15 , sqlite, libmysqlclient, nasm, gnutls, libva, libdrm
16 , curl, bzip2, zip, unzip, mesa-demos
17 , libcec, libcec_platform, dcadec, libuuid
18 , libcrossguid, libmicrohttpd
19 , bluez, doxygen, giflib, glib, harfbuzz, lcms2, libidn2, libpthreadstubs, libtasn1
20 , libplist, p11-kit, zlib, flatbuffers, fstrcmp, rapidjson
21 , lirc
22 , x11Support ? true, libX11, xorgproto, libXt, libXmu, libXext, libXinerama, libXrandr, libXtst, libXfixes, xdpyinfo, libXdmcp
23 , dbusSupport ? true, dbus
24 , joystickSupport ? true, cwiid
25 , nfsSupport ? true, libnfs
26 , pulseSupport ? true, libpulseaudio
27 , pipewireSupport ? true, pipewire
28 , rtmpSupport ? true, rtmpdump
29 , sambaSupport ? true, samba
30 , udevSupport ? true, udev
31 , opticalSupport ? true
32 , usbSupport  ? false, libusb-compat-0_1
33 , vdpauSupport ? true, libvdpau
34 , waylandSupport ? false, wayland, wayland-protocols
35 , waylandpp ?  null, libxkbcommon
36 , gbmSupport ? false, mesa, libinput, libdisplay-info
37 , buildPackages
40 assert usbSupport -> !udevSupport; # libusb-compat-0_1 won't be used if udev is available
41 assert gbmSupport || waylandSupport || x11Support;
43 let
44   # see https://github.com/xbmc/xbmc/blob/${kodiVersion}-${rel}/tools/depends/target/ to get suggested versions for all dependencies
46   # We can build these externally but FindLibDvd.cmake forces us to build it
47   # them, so we currently just use them for the src.
48   libdvdcss = fetchFromGitHub {
49     owner = "xbmc";
50     repo = "libdvdcss";
51     rev = "1.4.3-Next-Nexus-Alpha2-2";
52     sha256 = "sha256-CJMGH50mNAkovccNcol5ArF3zUnZKfbVB9EXyQgu5k4=";
53   };
55   libdvdnav = fetchFromGitHub {
56     owner = "xbmc";
57     repo = "libdvdnav";
58     rev = "6.1.1-Next-Nexus-Alpha2-2";
59     sha256 = "sha256-m8SCjOokVbwJ7eVfYKHap1pQjVbI+BXaoxhGZQIg0+k=";
60   };
62   libdvdread = fetchFromGitHub {
63     owner = "xbmc";
64     repo = "libdvdread";
65     rev = "6.1.3-Next-Nexus-Alpha2-2";
66     sha256 = "sha256-AphBQhXud+a6wm52zjzC5biz53NnqWdgpL2QDt2ZuXc=";
67   };
69   groovy = fetchzip {
70     url = "mirror://apache/groovy/4.0.16/distribution/apache-groovy-binary-4.0.16.zip";
71     sha256 = "sha256-OfZBiMVrhw6VqHRHCSC7ZV3FiZ26n4+F8hsskk+L6yU=";
72   };
74   apache_commons_lang = fetchzip {
75     url = "mirror://apache/commons/lang/binaries/commons-lang3-3.14.0-bin.zip";
76     sha512 = "sha512-eKF1IQ6PDtifb4pMHWQ2SYHIh0HbMi3qpc92lfbOo3uSsFJVR3n7JD0AdzrG17tLJQA4z5PGDhwyYw0rLeLsXw==";
77   };
79   apache_commons_text = fetchzip {
80     url = "mirror://apache/commons/text/binaries/commons-text-1.11.0-bin.zip";
81     sha512 = "sha512-P2IvnrHSYRF70LllTMI8aev43h2oe8lq6rrMYw450PEhEa7OuuCjh1Krnc/A4OqENUcidVAAX5dK1RAsZHh8Dg==";
82   };
84   kodi_platforms = lib.optional gbmSupport "gbm"
85     ++ lib.optional waylandSupport "wayland"
86     ++ lib.optional x11Support "x11";
88 in stdenv.mkDerivation (finalAttrs: {
89     pname = "kodi";
90     version = "21.1";
91     kodiReleaseName = "Omega";
93     src = fetchFromGitHub {
94       owner = "xbmc";
95       repo  = "xbmc";
96       rev   = "${finalAttrs.version}-${finalAttrs.kodiReleaseName}";
97       hash  = "sha256-NjId1T1cw9dl0Fx1QDsijiN1VUpuQ/EFl1kxWSESCR4=";
98     };
100     patches = [
101       ./no-python-lib.patch
102     ];
104     # make  derivations declared in the let binding available here, so
105     # they can be overridden
106     inherit libdvdcss libdvdnav libdvdread groovy
107             apache_commons_lang apache_commons_text;
109     buildInputs = [
110       gnutls libidn2 libtasn1 nasm p11-kit
111       libxml2 python3Packages.python
112       boost libmicrohttpd
113       gettext pcre-cpp yajl fribidi libva libdrm
114       openssl gperf tinyxml2 tinyxml-2 taglib libssh
115       gtest ncurses spdlog
116       alsa-lib libGL libGLU fontconfig freetype ftgl
117       libjpeg libpng libtiff
118       libmpeg2 libsamplerate libmad
119       libogg libvorbis flac libxslt systemd
120       lzo libcdio libmodplug libass libbluray libudfread
121       sqlite libmysqlclient avahi lame
122       curl bzip2 zip unzip mesa-demos
123       libcec libcec_platform dcadec libuuid
124       libxcrypt libgcrypt libgpg-error libunistring
125       libcrossguid libplist
126       bluez giflib glib harfbuzz lcms2 libpthreadstubs
127       ffmpeg flatbuffers fstrcmp rapidjson
128       lirc
129       mesa # for libEGL
130     ]
131     ++ lib.optionals x11Support [
132       libX11 xorgproto libXt libXmu libXext.dev libXdmcp
133       libXinerama libXrandr.dev libXtst libXfixes
134     ]
135     ++ lib.optional  dbusSupport     dbus
136     ++ lib.optional  joystickSupport cwiid
137     ++ lib.optional  nfsSupport      libnfs
138     ++ lib.optional  pulseSupport    libpulseaudio
139     ++ lib.optional  pipewireSupport pipewire
140     ++ lib.optional  rtmpSupport     rtmpdump
141     ++ lib.optional  sambaSupport    samba
142     ++ lib.optional  udevSupport     udev
143     ++ lib.optional  usbSupport      libusb-compat-0_1
144     ++ lib.optional  vdpauSupport    libvdpau
145     ++ lib.optionals waylandSupport [
146       wayland
147       waylandpp.dev
148       wayland-protocols
149       # Not sure why ".dev" is needed here, but CMake doesn't find libxkbcommon otherwise
150       libxkbcommon.dev
151     ]
152     ++ lib.optionals gbmSupport [
153       libxkbcommon.dev
154       mesa.dev
155       libinput.dev
156       libdisplay-info
157     ];
159     nativeBuildInputs = [
160       cmake
161       doxygen
162       makeWrapper
163       which
164       pkg-config
165       autoconf automake libtool # still needed for some components. Check if that is the case with 19.0
166       jre_headless yasm gettext python3Packages.python flatbuffers
168       # for TexturePacker
169       giflib zlib libpng libjpeg lzo
170     ] ++ lib.optionals waylandSupport [ wayland-protocols waylandpp.bin ];
172     depsBuildBuild = [
173       buildPackages.stdenv.cc
174     ];
176     cmakeFlags = [
177       "-DAPP_RENDER_SYSTEM=${if gbmSupport then "gles" else "gl"}"
178       "-Dlibdvdcss_URL=${finalAttrs.libdvdcss}"
179       "-Dlibdvdnav_URL=${finalAttrs.libdvdnav}"
180       "-Dlibdvdread_URL=${finalAttrs.libdvdread}"
181       "-Dgroovy_SOURCE_DIR=${finalAttrs.groovy}"
182       "-Dapache-commons-lang_SOURCE_DIR=${finalAttrs.apache_commons_lang}"
183       "-Dapache-commons-text_SOURCE_DIR=${finalAttrs.apache_commons_text}"
184       # Upstream derives this from the git HEADs hash and date.
185       # LibreElec (minimal distro for kodi) uses the equivalent to this.
186       "-DGIT_VERSION=${finalAttrs.version}-${finalAttrs.kodiReleaseName}"
187       "-DENABLE_EVENTCLIENTS=ON"
188       "-DENABLE_INTERNAL_CROSSGUID=OFF"
189       "-DENABLE_INTERNAL_RapidJSON=OFF"
190       "-DENABLE_OPTICAL=${if opticalSupport then "ON" else "OFF"}"
191       "-DENABLE_VDPAU=${if vdpauSupport then "ON" else "OFF"}"
192       "-DLIRC_DEVICE=/run/lirc/lircd"
193       "-DSWIG_EXECUTABLE=${buildPackages.swig}/bin/swig"
194       "-DFLATBUFFERS_FLATC_EXECUTABLE=${buildPackages.flatbuffers}/bin/flatc"
195       "-DPYTHON_EXECUTABLE=${buildPackages.python3Packages.python}/bin/python"
196       "-DPYTHON_LIB_PATH=${python3Packages.python.sitePackages}"
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       # TODO: figure out which binaries should be wrapped this way and which shouldn't
230       for p in $(ls --ignore=kodi-send $out/bin/) ; do
231         wrapProgram $out/bin/$p \
232           --prefix PATH ":" "${lib.makeBinPath ([ python3Packages.python mesa-demos ]
233             ++ lib.optional x11Support xdpyinfo ++ lib.optional sambaSupport samba)}" \
234           --prefix LD_LIBRARY_PATH ":" "${lib.makeLibraryPath
235               ([ curl systemd libmad libcec libcec_platform libass ]
236                  ++ lib.optional vdpauSupport libvdpau
237                  ++ lib.optional nfsSupport libnfs
238                  ++ lib.optional rtmpSupport rtmpdump)}"
239       done
241       wrapProgram $out/bin/kodi-send \
242         --prefix PYTHONPATH : $out/${python3Packages.python.sitePackages}
244       substituteInPlace $out/share/xsessions/kodi.desktop \
245         --replace kodi-standalone $out/bin/kodi-standalone
246     '';
248     doInstallCheck = true;
250     installCheckPhase = "$out/bin/kodi --version";
252     passthru = {
253       pythonPackages = python3Packages;
254       ffmpeg = ffmpeg;
255       kodi = finalAttrs.finalPackage;
256     };
258     meta = with lib; {
259       description = "Media center";
260       homepage    = "https://kodi.tv/";
261       license     = licenses.gpl2Plus;
262       platforms   = platforms.linux;
263       maintainers = teams.kodi.members;
264       mainProgram = "kodi";
265     };