1 { stdenv, lib, fetchFromGitHub, fetchzip
2 , autoconf, automake, libtool, makeWrapper
3 , pkg-config, cmake, yasm, python3Packages
4 , libxcrypt, libgcrypt, libgpg-error, libunistring
6 , gettext, pcre-cpp, yajl, fribidi, which
7 , openssl, gperf, tinyxml2, tinyxml-2, taglib, libssh, jre_headless
8 , gtest, ncurses, spdlog
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
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
40 assert usbSupport -> !udevSupport; # libusb-compat-0_1 won't be used if udev is available
41 assert gbmSupport || waylandSupport || x11Support;
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 {
51 rev = "1.4.3-Next-Nexus-Alpha2-2";
52 sha256 = "sha256-CJMGH50mNAkovccNcol5ArF3zUnZKfbVB9EXyQgu5k4=";
55 libdvdnav = fetchFromGitHub {
58 rev = "6.1.1-Next-Nexus-Alpha2-2";
59 sha256 = "sha256-m8SCjOokVbwJ7eVfYKHap1pQjVbI+BXaoxhGZQIg0+k=";
62 libdvdread = fetchFromGitHub {
65 rev = "6.1.3-Next-Nexus-Alpha2-2";
66 sha256 = "sha256-AphBQhXud+a6wm52zjzC5biz53NnqWdgpL2QDt2ZuXc=";
70 url = "mirror://apache/groovy/4.0.16/distribution/apache-groovy-binary-4.0.16.zip";
71 sha256 = "sha256-OfZBiMVrhw6VqHRHCSC7ZV3FiZ26n4+F8hsskk+L6yU=";
74 apache_commons_lang = fetchzip {
75 url = "mirror://apache/commons/lang/binaries/commons-lang3-3.14.0-bin.zip";
76 sha512 = "sha512-eKF1IQ6PDtifb4pMHWQ2SYHIh0HbMi3qpc92lfbOo3uSsFJVR3n7JD0AdzrG17tLJQA4z5PGDhwyYw0rLeLsXw==";
79 apache_commons_text = fetchzip {
80 url = "mirror://apache/commons/text/binaries/commons-text-1.11.0-bin.zip";
81 sha512 = "sha512-P2IvnrHSYRF70LllTMI8aev43h2oe8lq6rrMYw450PEhEa7OuuCjh1Krnc/A4OqENUcidVAAX5dK1RAsZHh8Dg==";
84 kodi_platforms = lib.optional gbmSupport "gbm"
85 ++ lib.optional waylandSupport "wayland"
86 ++ lib.optional x11Support "x11";
88 in stdenv.mkDerivation (finalAttrs: {
91 kodiReleaseName = "Omega";
93 src = fetchFromGitHub {
96 rev = "${finalAttrs.version}-${finalAttrs.kodiReleaseName}";
97 hash = "sha256-NjId1T1cw9dl0Fx1QDsijiN1VUpuQ/EFl1kxWSESCR4=";
101 ./no-python-lib.patch
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;
110 gnutls libidn2 libtasn1 nasm p11-kit
111 libxml2 python3Packages.python
113 gettext pcre-cpp yajl fribidi libva libdrm
114 openssl gperf tinyxml2 tinyxml-2 taglib libssh
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
131 ++ lib.optionals x11Support [
132 libX11 xorgproto libXt libXmu libXext.dev libXdmcp
133 libXinerama libXrandr.dev libXtst libXfixes
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 [
149 # Not sure why ".dev" is needed here, but CMake doesn't find libxkbcommon otherwise
152 ++ lib.optionals gbmSupport [
159 nativeBuildInputs = [
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
169 giflib zlib libpng libjpeg lzo
170 ] ++ lib.optionals waylandSupport [ wayland-protocols waylandpp.bin ];
173 buildPackages.stdenv.cc
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++"
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
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"
224 substituteInPlace xbmc/platform/posix/PosixTimezone.cpp \
225 --replace 'usr/share/zoneinfo' 'etc/zoneinfo'
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)}"
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
248 doInstallCheck = true;
250 installCheckPhase = "$out/bin/kodi --version";
253 pythonPackages = python3Packages;
255 kodi = finalAttrs.finalPackage;
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";