summary refs log tree commit diff
path: root/pkgs/applications/video/kodi/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/applications/video/kodi/default.nix')
-rw-r--r--pkgs/applications/video/kodi/default.nix84
1 files changed, 60 insertions, 24 deletions
diff --git a/pkgs/applications/video/kodi/default.nix b/pkgs/applications/video/kodi/default.nix
index d13dd3201a3..e4da20c8487 100644
--- a/pkgs/applications/video/kodi/default.nix
+++ b/pkgs/applications/video/kodi/default.nix
@@ -4,22 +4,20 @@
 , boost, avahi, lame, autoreconfHook
 , gettext, pcre-cpp, yajl, fribidi, which
 , openssl, gperf, tinyxml2, taglib, libssh, swig, jre
-, libX11, xorgproto, libxml2
-, libXt, libXmu, libXext
-, libXinerama, libXrandr
-, libXtst, libXfixes, systemd
+, libxml2, systemd
 , alsaLib, libGLU, libGL, glew, fontconfig, freetype, ftgl
 , libjpeg, libpng, libtiff
 , libmpeg2, libsamplerate, libmad
 , libogg, libvorbis, flac, libxslt
 , lzo, libcdio, libmodplug, libass, libbluray
 , sqlite, libmysqlclient, nasm, gnutls, libva, libdrm
-, curl, bzip2, zip, unzip, glxinfo, xdpyinfo
+, curl, bzip2, zip, unzip, glxinfo
 , libcec, libcec_platform, dcadec, libuuid
 , libcrossguid, libmicrohttpd
-, bluez, doxygen, giflib, glib, harfbuzz, lcms2, libidn, libpthreadstubs, libtasn1, libXdmcp
+, bluez, doxygen, giflib, glib, harfbuzz, lcms2, libidn, libpthreadstubs, libtasn1
 , libplist, p11-kit, zlib, flatbuffers, fmt, fstrcmp, rapidjson
 , lirc
+, x11Support ? true, libX11, xorgproto, libXt, libXmu, libXext, libXinerama, libXrandr, libXtst, libXfixes, xdpyinfo, libXdmcp
 , dbusSupport ? true, dbus ? null
 , joystickSupport ? true, cwiid ? null
 , nfsSupport ? true, libnfs ? null
@@ -27,11 +25,12 @@
 , rtmpSupport ? true, rtmpdump ? null
 , sambaSupport ? true, samba ? null
 , udevSupport ? true, udev ? null
-, usbSupport  ? false, libusb ? null
+, usbSupport  ? false, libusb-compat-0_1 ? null
 , vdpauSupport ? true, libvdpau ? null
 , useWayland ? false, wayland ? null, wayland-protocols ? null
 , waylandpp ?  null, libxkbcommon ? null
 , useGbm ? false, mesa ? null, libinput ? null
+, buildPackages
 }:
 
 assert dbusSupport  -> dbus != null;
@@ -40,7 +39,7 @@ assert pulseSupport -> libpulseaudio != null;
 assert rtmpSupport  -> rtmpdump != null;
 assert sambaSupport -> samba != null;
 assert udevSupport  -> udev != null;
-assert usbSupport   -> libusb != null && ! udevSupport; # libusb won't be used if udev is avaliable
+assert usbSupport   -> libusb-compat-0_1 != null && ! udevSupport; # libusb-compat-0_1 won't be used if udev is avaliable
 assert vdpauSupport -> libvdpau != null;
 assert useWayland -> wayland != null && wayland-protocols != null && waylandpp != null && libxkbcommon != null;
 
@@ -94,10 +93,18 @@ let
     sha256  = "1krsjlr949iy5l6ljxancza1yi6w1annxc5s6k283i9mb15qy8cy";
     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
     '';
-    buildInputs = [ gnutls libidn libtasn1 p11-kit zlib libva ]
+    cmakeFlags = lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
+      "-DCROSSCOMPILING=ON"
+      "-DCPU=${stdenv.hostPlatform.parsed.cpu.name}"
+      "-DOS=${stdenv.hostPlatform.parsed.kernel.name}"
+      "-DPKG_CONFIG_EXECUTABLE=pkgconfig"
+    ];
+    buildInputs = [ libidn libtasn1 p11-kit zlib libva ]
       ++ lib.optional  vdpauSupport    libvdpau;
-    nativeBuildInputs = [ cmake nasm pkgconfig ];
+    nativeBuildInputs = [ cmake nasm pkgconfig gnutls ];
   };
 
   # We can build these externally but FindLibDvd.cmake forces us to build it
@@ -152,38 +159,42 @@ in stdenv.mkDerivation {
 
     buildInputs = [
       gnutls libidn libtasn1 nasm p11-kit
-      libxml2 yasm python2Packages.python
+      libxml2 python2Packages.python
       boost libmicrohttpd
       gettext pcre-cpp yajl fribidi libva libdrm
-      openssl gperf tinyxml2 taglib libssh swig jre
-      libX11 xorgproto libXt libXmu libXext
-      libXinerama libXrandr libXtst libXfixes
-      alsaLib libGL libGLU glew fontconfig freetype ftgl
+      openssl gperf tinyxml2 taglib libssh
+      alsaLib libGL libGLU fontconfig freetype ftgl
       libjpeg libpng libtiff
       libmpeg2 libsamplerate libmad
       libogg libvorbis flac libxslt systemd
       lzo libcdio libmodplug libass libbluray
       sqlite libmysqlclient avahi lame
-      curl bzip2 zip unzip glxinfo xdpyinfo
+      curl bzip2 zip unzip glxinfo
       libcec libcec_platform dcadec libuuid
       libgcrypt libgpgerror libunistring
-      libcrossguid cwiid libplist
-      bluez giflib glib harfbuzz lcms2 libpthreadstubs libXdmcp
+      libcrossguid libplist
+      bluez giflib glib harfbuzz lcms2 libpthreadstubs
       ffmpeg flatbuffers fmt fstrcmp rapidjson
       lirc
       # libdvdcss libdvdnav libdvdread
     ]
+    ++ lib.optional x11Support [
+      libX11 xorgproto libXt libXmu libXext libXdmcp
+      libXinerama libXrandr libXtst libXfixes
+    ]
     ++ lib.optional  dbusSupport     dbus
-    ++ lib.optionals joystickSupport [ cwiid ]
+    ++ 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
+    ++ lib.optional  usbSupport      libusb-compat-0_1
     ++ lib.optional  vdpauSupport    libvdpau
     ++ lib.optionals useWayland [
-      wayland waylandpp
+      wayland 
+      waylandpp.dev 
+      wayland-protocols
       # Not sure why ".dev" is needed here, but CMake doesn't find libxkbcommon otherwise
       libxkbcommon.dev
     ]
@@ -200,7 +211,15 @@ in stdenv.mkDerivation {
       which
       pkgconfig gnumake
       autoconf automake libtool # still needed for some components. Check if that is the case with 19.0
-    ] ++ lib.optionals useWayland [ wayland-protocols ];
+      jre yasm gettext python2Packages.python flatbuffers
+
+      # for TexturePacker
+      giflib zlib libpng libjpeg lzo
+    ] ++ lib.optionals useWayland [ wayland-protocols waylandpp.bin ];
+
+    depsBuildBuild = [
+      buildPackages.stdenv.cc
+    ];
 
     cmakeFlags = [
       "-Dlibdvdcss_URL=${libdvdcss.src}"
@@ -210,9 +229,14 @@ in stdenv.mkDerivation {
       "-DENABLE_EVENTCLIENTS=ON"
       "-DENABLE_INTERNAL_CROSSGUID=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.python2Packages.python}/bin/python"
     ] ++ lib.optional useWayland [
       "-DCORE_PLATFORM_NAME=wayland"
       "-DWAYLAND_RENDER_SYSTEM=gl"
+      "-DWAYLANDPP_SCANNER=${buildPackages.waylandpp}/bin/wayland-scanner++"
     ] ++ lib.optional useGbm [
       "-DCORE_PLATFORM_NAME=gbm"
       "-DGBM_RENDER_SYSTEM=gles"
@@ -224,6 +248,16 @@ in stdenv.mkDerivation {
     # I'm guessing there is a thing waiting to time out
     doCheck = false;
 
+    # Need these tools on the build system when cross compiling,
+    # hacky, but have found no other way.
+    preConfigure = lib.optionalString (stdenv.hostPlatform != stdenv.buildPlatform) ''
+      CXX=c++ LD=ld make -C tools/depends/native/JsonSchemaBuilder
+      cmakeFlags+=" -DWITH_JSONSCHEMABUILDER=$PWD/tools/depends/native/JsonSchemaBuilder/bin"
+
+      CXX=c++ LD=ld make EXTRA_CONFIGURE= -C tools/depends/native/TexturePacker
+      cmakeFlags+=" -DWITH_TEXTUREPACKER=$PWD/tools/depends/native/TexturePacker/bin"
+    '';
+
     postPatch = ''
       substituteInPlace xbmc/platform/linux/LinuxTimezone.cpp \
         --replace 'usr/share/zoneinfo' 'etc/zoneinfo'
@@ -232,9 +266,11 @@ in stdenv.mkDerivation {
     postInstall = ''
       for p in $(ls $out/bin/) ; do
         wrapProgram $out/bin/$p \
-          --prefix PATH            ":" "${lib.makeBinPath [ python2Packages.python glxinfo xdpyinfo ]}" \
+          --prefix PATH            ":" "${lib.makeBinPath ([ python2Packages.python glxinfo ] ++ lib.optional x11Support xdpyinfo)}" \
           --prefix LD_LIBRARY_PATH ":" "${lib.makeLibraryPath
-              ([ curl systemd libmad libvdpau libcec libcec_platform rtmpdump libass ] ++ lib.optional nfsSupport libnfs)}"
+              ([ curl systemd libmad libvdpau libcec libcec_platform libass ]
+                 ++ lib.optional nfsSupport libnfs
+                 ++ lib.optional rtmpSupport rtmpdump)}"
       done
 
       substituteInPlace $out/share/xsessions/kodi.desktop \