1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
|
{ stdenv, lib, fetchFromGitHub, autoconf, automake, libtool, makeWrapper
, pkg-config, cmake, yasm, python3Packages
, libxcrypt, libgcrypt, libgpg-error, libunistring
, boost, avahi, lame
, gettext, pcre-cpp, yajl, fribidi, which
, openssl, gperf, tinyxml2, taglib, libssh, swig, jre_headless
, gtest, ncurses, spdlog
, libxml2, systemd
, alsa-lib, libGLU, libGL, fontconfig, freetype, ftgl
, libjpeg, libpng, libtiff
, libmpeg2, libsamplerate, libmad
, libogg, libvorbis, flac, libxslt
, lzo, libcdio, libmodplug, libass, libbluray, libudfread
, sqlite, libmysqlclient, nasm, gnutls, libva, libdrm
, curl, bzip2, zip, unzip, glxinfo
, libcec, libcec_platform, dcadec, libuuid
, libcrossguid, libmicrohttpd
, bluez, doxygen, giflib, glib, harfbuzz, lcms2, libidn2, 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 available
assert gbmSupport || waylandSupport || x11Support;
let
kodiReleaseDate = "20230312";
kodiVersion = "20.1";
rel = "Nexus";
kodi_src = fetchFromGitHub {
owner = "xbmc";
repo = "xbmc";
rev = "${kodiVersion}-${rel}";
hash = "sha256-2nwjW0MYrMVk+dllrAv9yn+YNA6/loZzoK8mbFIZ8Xs=";
};
# see https://github.com/xbmc/xbmc/blob/${kodiVersion}-${rel}/tools/depends/target/ to get suggested versions for all dependencies
# kodi 20.0 moved to ffmpeg 5, *but* there is a bug making the compilation fail which will
# only been fixed in kodi 21, so stick to ffmpeg 4 for now
ffmpeg = stdenv.mkDerivation rec {
pname = "kodi-ffmpeg";
version = "4.4.1";
src = fetchFromGitHub {
owner = "xbmc";
repo = "FFmpeg";
rev = "${version}-${rel}-Alpha1";
sha256 = "sha256-EQHmmWnDw+/udKYq7Nrf00nL7I5XWUtmzdauDryfTII=";
};
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 = [ libidn2 libtasn1 p11-kit zlib libva ]
++ lib.optional vdpauSupport libvdpau;
nativeBuildInputs = [ cmake nasm pkg-config gnutls ];
};
# We can build these externally but FindLibDvd.cmake forces us to build it
# them, so we currently just use them for the src.
libdvdcss = fetchFromGitHub {
owner = "xbmc";
repo = "libdvdcss";
rev = "1.4.3-Next-Nexus-Alpha2-2";
sha256 = "sha256-CJMGH50mNAkovccNcol5ArF3zUnZKfbVB9EXyQgu5k4=";
};
libdvdnav = fetchFromGitHub {
owner = "xbmc";
repo = "libdvdnav";
rev = "6.1.1-Next-Nexus-Alpha2-2";
sha256 = "sha256-m8SCjOokVbwJ7eVfYKHap1pQjVbI+BXaoxhGZQIg0+k=";
};
libdvdread = fetchFromGitHub {
owner = "xbmc";
repo = "libdvdread";
rev = "6.1.3-Next-Nexus-Alpha2-2";
sha256 = "sha256-AphBQhXud+a6wm52zjzC5biz53NnqWdgpL2QDt2ZuXc=";
};
kodi_platforms = lib.optional gbmSupport "gbm"
++ lib.optional waylandSupport "wayland"
++ lib.optional x11Support "x11";
in stdenv.mkDerivation {
pname = "kodi";
version = kodiVersion;
src = kodi_src;
buildInputs = [
gnutls libidn2 libtasn1 nasm p11-kit
libxml2 python3Packages.python
boost libmicrohttpd
gettext pcre-cpp yajl fribidi libva libdrm
openssl gperf tinyxml2 taglib libssh
gtest ncurses spdlog
alsa-lib libGL libGLU fontconfig freetype ftgl
libjpeg libpng libtiff
libmpeg2 libsamplerate libmad
libogg libvorbis flac libxslt systemd
lzo libcdio libmodplug libass libbluray libudfread
sqlite libmysqlclient avahi lame
curl bzip2 zip unzip glxinfo
libcec libcec_platform dcadec libuuid
libxcrypt libgcrypt libgpg-error libunistring
libcrossguid libplist
bluez giflib glib harfbuzz lcms2 libpthreadstubs
ffmpeg flatbuffers fstrcmp rapidjson
lirc
mesa # for libEGL
]
++ lib.optionals x11Support [
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
++ lib.optional usbSupport libusb-compat-0_1
++ lib.optional vdpauSupport libvdpau
++ lib.optionals waylandSupport [
wayland
waylandpp.dev
wayland-protocols
# Not sure why ".dev" is needed here, but CMake doesn't find libxkbcommon otherwise
libxkbcommon.dev
]
++ lib.optionals gbmSupport [
libxkbcommon.dev
mesa.dev
libinput.dev
];
nativeBuildInputs = [
cmake
doxygen
makeWrapper
which
pkg-config
autoconf automake libtool # still needed for some components. Check if that is the case with 19.0
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"}"
"-Dlibdvdcss_URL=${libdvdcss}"
"-Dlibdvdnav_URL=${libdvdnav}"
"-Dlibdvdread_URL=${libdvdread}"
"-DGIT_VERSION=${kodiReleaseDate}"
"-DENABLE_EVENTCLIENTS=ON"
"-DENABLE_INTERNAL_CROSSGUID=OFF"
"-DENABLE_INTERNAL_RapidJSON=OFF"
"-DENABLE_OPTICAL=ON"
"-DLIRC_DEVICE=/run/lirc/lircd"
"-DSWIG_EXECUTABLE=${buildPackages.swig}/bin/swig"
"-DFLATBUFFERS_FLATC_EXECUTABLE=${buildPackages.flatbuffers}/bin/flatc"
"-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.optionals 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;
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.
CXX=$CXX_FOR_BUILD LD=ld make -C tools/depends/native/JsonSchemaBuilder
cmakeFlags+=" -DWITH_JSONSCHEMABUILDER=$PWD/tools/depends/native/JsonSchemaBuilder/bin"
CXX=$CXX_FOR_BUILD LD=ld make EXTRA_CONFIGURE= -C tools/depends/native/TexturePacker
cmakeFlags+=" -DWITH_TEXTUREPACKER=$PWD/tools/depends/native/TexturePacker/bin"
'';
postPatch = ''
substituteInPlace xbmc/platform/posix/PosixTimezone.cpp \
--replace 'usr/share/zoneinfo' 'etc/zoneinfo'
'';
postInstall = ''
# TODO: figure out which binaries should be wrapped this way and which shouldn't
for p in $(ls --ignore=kodi-send $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
wrapProgram $out/bin/kodi-send \
--prefix PYTHONPATH : $out/${python3Packages.python.sitePackages}
substituteInPlace $out/share/xsessions/kodi.desktop \
--replace kodi-standalone $out/bin/kodi-standalone
'';
doInstallCheck = true;
installCheckPhase = "$out/bin/kodi --version";
passthru = {
pythonPackages = python3Packages;
ffmpeg = ffmpeg;
};
meta = with lib; {
description = "Media center";
homepage = "https://kodi.tv/";
license = licenses.gpl2Plus;
platforms = platforms.linux;
maintainers = teams.kodi.members;
};
}
|