summary refs log tree commit diff
path: root/pkgs/applications/video/kodi/plugins.nix
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/applications/video/kodi/plugins.nix')
-rw-r--r--pkgs/applications/video/kodi/plugins.nix129
1 files changed, 106 insertions, 23 deletions
diff --git a/pkgs/applications/video/kodi/plugins.nix b/pkgs/applications/video/kodi/plugins.nix
index 5a0583202e6d..f2ceacdd799f 100644
--- a/pkgs/applications/video/kodi/plugins.nix
+++ b/pkgs/applications/video/kodi/plugins.nix
@@ -1,9 +1,90 @@
 { stdenv, callPackage, fetchurl, fetchFromGitHub, unzip
+, cmake, kodiPlain, libcec_platform, tinyxml
 , steam, libusb, pcre-cpp, jsoncpp, libhdhomerun, zlib }:
 
-with (callPackage ./commons.nix {});
+with stdenv.lib;
 
-rec {
+let self = rec {
+
+  pluginDir = "/share/kodi/addons";
+
+  kodi = kodiPlain;
+
+  # Convert derivation to a kodi module. Stolen from ../../../top-level/python-packages.nix
+  toKodiPlugin = drv: drv.overrideAttrs(oldAttrs: {
+    # Use passthru in order to prevent rebuilds when possible.
+    passthru = (oldAttrs.passthru or {})// {
+      kodiPluginFor = kodi;
+      requiredKodiPlugins = requiredKodiPlugins drv.propagatedBuildInputs;
+    };
+  });
+
+  # Check whether a derivation provides a Kodi plugin.
+  hasKodiPlugin = drv: drv ? kodiPluginFor && drv.kodiPluginFor == kodi;
+
+  # Get list of required Kodi plugins given a list of derivations.
+  requiredKodiPlugins = drvs: let
+      modules = filter hasKodiPlugin drvs;
+    in unique (modules ++ concatLists (catAttrs "requiredKodiPlugins" modules));
+
+  kodiWithPlugins = func: callPackage ./wrapper.nix {
+    inherit kodi;
+    plugins = requiredKodiPlugins (func self);
+  };
+
+  kodi-platform = stdenv.mkDerivation rec {
+    project = "kodi-platform";
+    version = "17.1";
+    name = "${project}-${version}";
+
+    src = fetchFromGitHub {
+      owner = "xbmc";
+      repo = project;
+      rev = "c8188d82678fec6b784597db69a68e74ff4986b5";
+      sha256 = "1r3gs3c6zczmm66qcxh9mr306clwb3p7ykzb70r3jv5jqggiz199";
+    };
+
+    buildInputs = [ cmake kodiPlain libcec_platform tinyxml ];
+  };
+
+  mkKodiPlugin = { plugin, namespace, version, sourceDir ? null, ... }@args:
+  toKodiPlugin (stdenv.mkDerivation (rec {
+    name = "kodi-plugin-${plugin}-${version}";
+
+    dontStrip = true;
+
+    installPhase = ''
+      ${if isNull sourceDir then "" else "cd $src/$sourceDir"}
+      d=$out${pluginDir}/${namespace}
+      mkdir -p $d
+      sauce="."
+      [ -d ${namespace} ] && sauce=${namespace}
+      cp -R "$sauce/"* $d
+    '';
+  } // args));
+
+  mkKodiABIPlugin = { plugin, namespace, version, extraBuildInputs ? [], ... }@args:
+  toKodiPlugin (stdenv.mkDerivation (rec {
+    name = "kodi-plugin-${plugin}-${version}";
+
+    dontStrip = true;
+
+    buildInputs = [ cmake kodiPlain kodi-platform libcec_platform ]
+               ++ extraBuildInputs;
+
+    # disables check ensuring install prefix is that of kodi
+    cmakeFlags = [
+      "-DOVERRIDE_PATHS=1"
+    ];
+
+    # kodi checks for plugin .so libs existance in the addon folder (share/...)
+    # and the non-wrapped kodi lib/... folder before even trying to dlopen
+    # them. Symlinking .so, as setting LD_LIBRARY_PATH is of no use
+    installPhase = let n = namespace; in ''
+      make install
+      ln -s $out/lib/addons/${n}/${n}.so.${version} $out${pluginDir}/${n}/${n}.so.${version}
+    '';
+  } // args));
 
   advanced-launcher = mkKodiPlugin rec {
 
@@ -18,7 +99,7 @@ rec {
       sha256 = "142vvgs37asq5m54xqhjzqvgmb0xlirvm0kz6lxaqynp0vvgrkx2";
     };
 
-    meta = with stdenv.lib; {
+    meta = {
       homepage = https://forum.kodi.tv/showthread.php?tid=85724;
       description = "A program launcher for Kodi";
       longDescription = ''
@@ -48,7 +129,7 @@ rec {
       sha256 = "1sv9z77jj6bam6llcnd9b3dgkbvhwad2m1v541rv3acrackms2z2";
     };
 
-    meta = with stdenv.lib; {
+    meta = {
       homepage = https://forum.kodi.tv/showthread.php?tid=287826;
       description = "A program launcher for Kodi";
       longDescription = ''
@@ -75,7 +156,7 @@ rec {
       sha256 = "0sbc0w0fwbp7rbmbgb6a1kglhnn5g85hijcbbvf5x6jdq9v3f1qb";
     };
 
-    meta = with stdenv.lib; {
+    meta = {
       description = "Add support for different gaming controllers.";
       platforms = platforms.all;
       maintainers = with maintainers; [ edwtjo ];
@@ -99,7 +180,7 @@ rec {
     // (mkController "ps")
     // (mkController "snes");
 
-  exodus = (mkKodiPlugin rec {
+  exodus = mkKodiPlugin rec {
 
     plugin = "exodus";
     namespace = "plugin.video.exodus";
@@ -110,13 +191,14 @@ rec {
       sha256 = "1zyay7cinljxmpzngzlrr4pnk2a7z9wwfdcsk6a4p416iglyggdj";
     };
 
-    meta = with stdenv.lib; {
+    buildInputs = [ unzip ];
+
+    meta = {
       description = "A streaming plugin for Kodi";
       platforms = platforms.all;
       maintainers = with maintainers; [ edwtjo ];
     };
-
-  }).override { buildInputs = [ unzip ]; };
+  };
 
   hyper-launcher = let
     pname = "hyper-launcher";
@@ -128,7 +210,7 @@ rec {
       rev = "f958ba93fe85b9c9025b1745d89c2db2e7dd9bf6";
       sha256 = "1dvff24fbas25k5kvca4ssks9l1g5rfa3hl8lqxczkaqi3pp41j5";
     };
-    meta = with stdenv.lib; {
+    meta = {
       homepage = https://forum.kodi.tv/showthread.php?tid=258159;
       description = "A ROM launcher for Kodi that uses HyperSpin assets.";
       maintainers = with maintainers; [ edwtjo ];
@@ -159,7 +241,7 @@ rec {
       sha256 = "18m61v8z9fbh4imvzhh4g9629r9df49g2yk9ycaczirg131dhfbh";
     };
 
-    meta = with stdenv.lib; {
+    meta = {
       description = "Binary addon for raw joystick input.";
       platforms = platforms.all;
       maintainers = with maintainers; [ edwtjo ];
@@ -183,7 +265,7 @@ rec {
       sha256 = "0klk1jpjc243ak306k94mag4b4s17w68v69yb8lzzydszqkaqa7x";
     };
 
-    meta = with stdenv.lib; {
+    meta = {
       homepage = https://forum.kodi.tv/showthread.php?tid=67110;
       description = "Watch content from SVT Play";
       longDescription = ''
@@ -212,7 +294,7 @@ rec {
 
     extraBuildInputs = [ libusb ];
 
-    meta = with stdenv.lib; {
+    meta = {
       description = "Binary addon for steam controller.";
       platforms = platforms.all;
       maintainers = with maintainers; [ edwtjo ];
@@ -220,7 +302,7 @@ rec {
 
   };
 
-  steam-launcher = (mkKodiPlugin rec {
+  steam-launcher = mkKodiPlugin rec {
 
     plugin = "steam-launcher";
     namespace = "script.steam.launcher";
@@ -233,7 +315,9 @@ rec {
       sha256 = "001a7zs3a4jfzj8ylxv2klc33mipmqsd5aqax7q81fbgwdlndvbm";
     };
 
-    meta = with stdenv.lib; {
+    propagatedBuildInputs = [ steam ];
+
+    meta = {
       homepage = https://forum.kodi.tv/showthread.php?tid=157499;
       description = "Launch Steam in Big Picture Mode from Kodi";
       longDescription = ''
@@ -245,8 +329,6 @@ rec {
       '';
       maintainers = with maintainers; [ edwtjo ];
     };
-  }).override {
-    propagatedBuildinputs = [ steam ];
   };
 
   pdfreader = mkKodiPlugin rec {
@@ -262,7 +344,7 @@ rec {
       sha256 = "1iv7d030z3xvlflvp4p5v3riqnwg9g0yvzxszy63v1a6x5kpjkqa";
     };
 
-    meta = with stdenv.lib; {
+    meta = {
       homepage = https://forum.kodi.tv/showthread.php?tid=187421;
       description = "A comic book reader";
       maintainers = with maintainers; [ edwtjo ];
@@ -282,7 +364,7 @@ rec {
       sha256 = "0pmlgqr4kd0gvckz77mj6v42kcx6lb23anm8jnf2fbn877snnijx";
     };
 
-    meta = with stdenv.lib; {
+    meta = {
       homepage = https://github.com/kodi-pvr/pvr.hts;
       description = "Kodi's Tvheadend HTSP client addon";
       platforms = platforms.all;
@@ -304,7 +386,7 @@ rec {
       sha256 = "0dvdv0vk2q12nj0i5h51iaypy3i7jfsxjyxwwpxfy82y8260ragy";
     };
 
-    meta = with stdenv.lib; {
+    meta = {
       homepage = https://github.com/kodi-pvr/pvr.hdhomerun;
       description = "Kodi's HDHomeRun PVR client addon";
       platforms = platforms.all;
@@ -328,7 +410,7 @@ rec {
       sha256 = "1f1im2gachrxnr3z96h5cg2c13vapgkvkdwvrbl4hxlnyp1a6jyz";
     };
 
-    meta = with stdenv.lib; {
+    meta = {
       homepage = https://github.com/kodi-pvr/pvr.iptvsimple;
       description = "Kodi's IPTV Simple client addon";
       platforms = platforms.all;
@@ -352,7 +434,7 @@ rec {
       sha256 = "1b3fm02annsq58pcfc985glrmh21rmqksdj3q8wn6gyza06jdf3v";
     };
 
-    meta = with stdenv.lib; {
+    meta = {
       homepage = https://github.com/osmc/skin.osmc;
       description = "The default skin for OSMC";
       platforms = platforms.all;
@@ -360,4 +442,5 @@ rec {
       license = licenses.cc-by-nc-sa-30;
     };
   };
-}
+
+}; in self