@@ -1,6 +1,7 @@
1−{ stdenv, lib, fetchurl, makeWrapper
1+{ stdenv, lib, fetchFromGitHub, fetchurl, autoconf, automake, libtool, makeWrapper
22, pkgconfig, cmake, gnumake, yasm, python2
3−, boost, avahi, libdvdcss, libdvdnav, libdvdread, lame, autoreconfHook
3+, libgcrypt, libgpgerror, libunistring
4+, boost, avahi, lame, autoreconfHook
45, gettext, pcre-cpp, yajl, fribidi, which
56, openssl, gperf, tinyxml2, taglib, libssh, swig, jre
67, libX11, xproto, inputproto, libxml2
@@ -16,133 +17,194 @@
1617, sqlite, mysql, nasm, gnutls, libva, wayland
1718, curl, bzip2, zip, unzip, glxinfo, xdpyinfo
1819, libcec, libcec_platform, dcadec, libuuid
19−, libcrossguid
20−, dbus_libs ? null, dbusSupport ? true
21−, udev, udevSupport ? true
22−, libusb ? null, usbSupport ? false
23−, samba ? null, sambaSupport ? true
24−, libmicrohttpd, bash
25−# TODO: would be nice to have nfsSupport (needs libnfs library)
26−, rtmpdump ? null, rtmpSupport ? true
27−, libvdpau ? null, vdpauSupport ? true
28−, libpulseaudio ? null, pulseSupport ? true
29−, joystickSupport ? true
20+, libcrossguid, libmicrohttpd
21+, bluez, doxygen, giflib, glib, harfbuzz, lcms2, libidn, libpthreadstubs, libtasn1, libXdmcp
22+, libplist, p11_kit, zlib
23+, dbusSupport ? true, dbus_libs ? null
24+, joystickSupport ? true, cwiid ? null
25+, nfsSupport ? true, libnfs ? null
26+, pulseSupport ? true, libpulseaudio ? null
27+, rtmpSupport ? true, rtmpdump ? null
28+, sambaSupport ? true, samba ? null
29+, udevSupport ? true, udev ? null
30+, usbSupport ? false, libusb ? null
31+, vdpauSupport ? true, libvdpau ? null
3032}:
3133
3234assert dbusSupport -> dbus_libs != null;
35+assert nfsSupport -> libnfs != null;
36+assert pulseSupport -> libpulseaudio != null;
37+assert rtmpSupport -> rtmpdump != null;
38+assert sambaSupport -> samba != null;
3339assert udevSupport -> udev != null;
3440assert usbSupport -> libusb != null && ! udevSupport; # libusb won't be used if udev is avaliable
35−assert sambaSupport -> samba != null;
3641assert vdpauSupport -> libvdpau != null;
37−assert pulseSupport -> libpulseaudio != null;
38−assert rtmpSupport -> rtmpdump != null;
42+
43+# TODO for Kodi 18.0
44+# - cmake is no longer in project/cmake
45+# - maybe we can remove auto{conf,make} and libtool from inputs
46+# - check if dbus support PR has been merged and add dbus as a buildInput
3947
4048let
41− kodi_version = "17.4";
49+ kodiReleaseDate = "20171115";
50+ kodiVersion = "17.6";
4251 rel = "Krypton";
43− ffmpeg_3_1_9 = fetchurl {
44− url = "https://github.com/xbmc/FFmpeg/archive/3.1.9-${rel}-${kodi_version}.tar.gz";
45− sha256 = "0rhjz505ljfg2jqbm3rd7qbcjq4vnp8h9a8vad8rjf84v3alglpa";
52+
53+ kodi_src = fetchFromGitHub {
54+ owner = "xbmc";
55+ repo = "xbmc";
56+ rev = "${kodiVersion}-${rel}";
57+ sha256 = "1pwmmbry7dajwdpmc1mdygjvxna4kl38h32d71g10yf3mdm5wmz3";
4658 };
47− # Usage of kodi fork of libdvdnav and libdvdread is necessary for functional dvd playback:
48− libdvdnav_src = fetchurl {
49− url = "https://github.com/xbmc/libdvdnav/archive/981488f.tar.gz";
50− sha256 = "312b3d15bc448d24e92f4b2e7248409525eccc4e75776026d805478e51c5ef3d";
59+
60+ kodiDependency = { name, version, rev, sha256, ... } @attrs:
61+ let
62+ attrs' = builtins.removeAttrs attrs ["name" "version" "rev" "sha256"];
63+ in stdenv.mkDerivation ({
64+ name = "kodi-${lib.toLower name}-${version}";
65+ src = fetchFromGitHub {
66+ owner = "xbmc";
67+ repo = name;
68+ inherit rev sha256;
69+ };
70+ enableParallelBuilding = true;
71+ } // attrs');
72+
73+ ffmpeg = kodiDependency rec {
74+ name = "FFmpeg";
75+ version = "3.1.11";
76+ rev = "${version}-${rel}-17.5"; # TODO: change 17.5 back to ${kodiVersion}
77+ sha256 = "0nc4sb6v1g3l11v9h5l9n44a8r40186rcbp2xg5c7vg6wcpjid13";
78+ preConfigure = ''
79+ cp ${kodi_src}/tools/depends/target/ffmpeg/{CMakeLists.txt,*.cmake} .
80+ '';
81+ buildInputs = [ gnutls libidn libtasn1 p11_kit zlib ];
82+ nativeBuildInputs = [ cmake nasm pkgconfig ];
5183 };
52− libdvdread_src = fetchurl {
53− url = "https://github.com/xbmc/libdvdread/archive/17d99db.tar.gz";
54− sha256 = "e7179b2054163652596a56301c9f025515cb08c6d6310b42b897c3ad11c0199b";
84+
85+ # we should be able to build these externally and have kodi reference them as buildInputs.
86+ # Doesn't work ATM though so we just use them for the src
87+
88+ libdvdcss = kodiDependency {
89+ name = "libdvdcss";
90+ version = "20160215";
91+ rev = "2f12236bc1c92f73c21e973363f79eb300de603f";
92+ sha256 = "198r0q73i55ga1dvyqq9nfcri0zq08b94hy8671lg14i3izx44dd";
93+ buildInputs = [ libdvdread ];
94+ nativeBuildInputs = [ autoreconfHook pkgconfig ];
95+ };
96+
97+ libdvdnav = kodiDependency {
98+ name = "libdvdnav";
99+ version = "20170217";
100+ rev = "981488f7f27554b103cca10c1fbeba027396c94a";
101+ sha256 = "089pswc51l3avh95zl4cpsh7gh1innh7b2y4xgx840mcmy46ycr8";
102+ buildInputs = [ libdvdread ];
103+ nativeBuildInputs = [ autoreconfHook pkgconfig ];
55104 };
105+
106+ libdvdread = kodiDependency {
107+ name = "libdvdread";
108+ version = "20160221";
109+ rev = "17d99db97e7b8f23077b342369d3c22a6250affd";
110+ sha256 = "1gr5aq1cjr3as9mnwrw29cxn4m6f6pfrxdahkdcjy70q3ldg90sl";
111+ nativeBuildInputs = [ autoreconfHook pkgconfig ];
112+ };
113+
56114in stdenv.mkDerivation rec {
57− version = kodi_version;
58− name = "kodi-${version}";
115+ name = "kodi-${kodiVersion}";
59116
60− src = fetchurl {
61− url = "https://github.com/xbmc/xbmc/archive/${version}-${rel}.tar.gz";
62− sha256 = "1p1lxkapynjbd85ns7m4jybl4k35kxzv7105xkh03hlz8kkqc23b";
63− };
117+ src = kodi_src;
64118
65119 buildInputs = [
66− libxml2 gnutls yasm python2
120+ gnutls libidn libtasn1 nasm p11_kit
121+ libxml2 yasm python2
67122 boost libmicrohttpd
68123 gettext pcre-cpp yajl fribidi libva
69124 openssl gperf tinyxml2 taglib libssh swig jre
70− libX11 xproto inputproto which
71− libXt libXmu libXext xextproto
72− libXinerama libXrandr randrproto
73− libXtst libXfixes fixesproto
125+ libX11 xproto inputproto libXt libXmu libXext xextproto
126+ libXinerama libXrandr randrproto libXtst libXfixes fixesproto
74127 SDL SDL_image SDL_mixer alsaLib
75128 mesa glew fontconfig freetype ftgl
76− libjpeg jasper libpng libtiff wayland
129+ libjpeg jasper libpng libtiff libva wayland
77130 libmpeg2 libsamplerate libmad
78131 libogg libvorbis flac libxslt systemd
79132 lzo libcdio libmodplug libass libbluray
80− sqlite mysql.lib nasm avahi libdvdcss lame
133+ sqlite mysql.lib avahi lame
81134 curl bzip2 zip unzip glxinfo xdpyinfo
82135 libcec libcec_platform dcadec libuuid
83− libcrossguid
136+ libgcrypt libgpgerror libunistring
137+ libcrossguid cwiid libplist
138+ bluez giflib glib harfbuzz lcms2 libpthreadstubs libXdmcp
139+ ffmpeg
140+ # libdvdcss libdvdnav libdvdread
84141 ]
85− ++ lib.optional dbusSupport dbus_libs
86− ++ lib.optional udevSupport udev
87− ++ lib.optional usbSupport libusb
88− ++ lib.optional sambaSupport samba
89− ++ lib.optional vdpauSupport libvdpau
90− ++ lib.optional pulseSupport libpulseaudio
91− ++ lib.optional rtmpSupport rtmpdump
92− ++ lib.optional joystickSupport SDL2;
142+ ++ lib.optional dbusSupport dbus_libs
143+ ++ lib.optionals joystickSupport [ cwiid SDL2 ]
144+ ++ lib.optional nfsSupport libnfs
145+ ++ lib.optional pulseSupport libpulseaudio
146+ ++ lib.optional rtmpSupport rtmpdump
147+ ++ lib.optional sambaSupport samba
148+ ++ lib.optional udevSupport udev
149+ ++ lib.optional usbSupport libusb
150+ ++ lib.optional vdpauSupport libvdpau;
93151
94152 nativeBuildInputs = [
95− autoreconfHook cmake gnumake makeWrapper pkgconfig
153+ cmake
154+ doxygen
155+ makeWrapper
156+ which
157+ pkgconfig gnumake
158+ autoconf automake libtool # still needed for some components. Check if that is the case with 18.0
96159 ];
97160
98− dontUseCmakeConfigure = true;
161+ cmakeFlags = [
162+ "-Dlibdvdcss_URL=${libdvdcss.src}"
163+ "-Dlibdvdnav_URL=${libdvdnav.src}"
164+ "-Dlibdvdread_URL=${libdvdread.src}"
165+ "-DGIT_VERSION=${kodiReleaseDate}"
166+ "-DENABLE_EVENTCLIENTS=ON"
167+ "-DENABLE_INTERNAL_CROSSGUID=OFF"
168+ "-DENABLE_OPTICAL=ON"
169+ "-DLIRC_DEVICE=/run/lirc/lircd"
170+ ];
171+
172+ enableParallelBuilding = true;
173+
174+ # 14 tests fail but the biggest issue is that every test takes 30 seconds -
175+ # I'm guessing there is a thing waiting to time out
176+ doCheck = false;
99177
100178 postPatch = ''
101179 substituteInPlace xbmc/linux/LinuxTimezone.cpp \
102180 --replace 'usr/share/zoneinfo' 'etc/zoneinfo'
103− substituteInPlace tools/depends/target/ffmpeg/autobuild.sh \
104− --replace "/bin/bash" "${bash}/bin/bash -ex"
105− cp ${ffmpeg_3_1_9} tools/depends/target/ffmpeg/ffmpeg-3.1.9-${rel}-${version}.tar.gz
106− ln -s ${libdvdcss.src} tools/depends/target/libdvdcss/libdvdcss-master.tar.gz
107− cp ${libdvdnav_src} tools/depends/target/libdvdnav/libdvdnav-master.tar.gz
108− cp ${libdvdread_src} tools/depends/target/libdvdread/libdvdread-master.tar.gz
109181 '';
110182
111183 preConfigure = ''
112− patchShebangs .
113− ./bootstrap
114− # tests here fail
115− sed -i '/TestSystemInfo.cpp/d' xbmc/utils/test/{Makefile,CMakeLists.txt}
116− # tests here trigger a segfault in kodi.bin
117− sed -i '/TestWebServer.cpp/d' xbmc/network/test/{Makefile,CMakeLists.txt}
184+ cd project/cmake
118185 '';
119186
120− enableParallelBuilding = true;
121−
122− doCheck = true;
123−
124− configureFlags = [ "--enable-libcec" ]
125− ++ lib.optional (!sambaSupport) "--disable-samba"
126− ++ lib.optional vdpauSupport "--enable-vdpau"
127− ++ lib.optional pulseSupport "--enable-pulse"
128− ++ lib.optional rtmpSupport "--enable-rtmp"
129− ++ lib.optional joystickSupport "--enable-joystick";
130−
131187 postInstall = ''
132188 for p in $(ls $out/bin/) ; do
133189 wrapProgram $out/bin/$p \
134− --prefix PATH ":" "${lib.makeBinPath
135− [ python2 glxinfo xdpyinfo ]}" \
190+ --prefix PATH ":" "${lib.makeBinPath [ python2 glxinfo xdpyinfo ]}" \
136191 --prefix LD_LIBRARY_PATH ":" "${lib.makeLibraryPath
137192 [ curl systemd libmad libvdpau libcec libcec_platform rtmpdump libass SDL2 ]}"
138193 done
194+
195+ substituteInPlace $out/share/xsessions/kodi.desktop \
196+ --replace kodi-standalone $out/bin/kodi-standalone
139197 '';
140198
199+ doInstallCheck = true;
200+
201+ installCheckPhase = "$out/bin/kodi --version";
202+
141203 meta = with stdenv.lib; {
142− homepage = https://kodi.tv/;
143204 description = "Media center";
144− license = licenses.gpl2;
145− platforms = platforms.linux;
146− maintainers = with maintainers; [ domenkozar titanous edwtjo ];
205+ homepage = https://kodi.tv/;
206+ license = licenses.gpl2;
207+ platforms = platforms.linux;
208+ maintainers = with maintainers; [ domenkozar titanous edwtjo peterhoeg ];
147209 };
148210}