From 574f2a33c05ccfebe125229468a8540713f6d33b Mon Sep 17 00:00:00 2001 From: Jan Malakhovski Date: Thu, 6 Sep 2018 19:40:14 +0000 Subject: [PATCH 1/6] kodiPlugins.steam-launcher: fix what is clearly a bug --- pkgs/applications/video/kodi/plugins.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/applications/video/kodi/plugins.nix b/pkgs/applications/video/kodi/plugins.nix index 5a0583202e6d..2ba23e72a2ed 100644 --- a/pkgs/applications/video/kodi/plugins.nix +++ b/pkgs/applications/video/kodi/plugins.nix @@ -246,7 +246,7 @@ rec { maintainers = with maintainers; [ edwtjo ]; }; }).override { - propagatedBuildinputs = [ steam ]; + propagatedBuildInputs = [ steam ]; }; pdfreader = mkKodiPlugin rec { From 88d69df250a546952666ead4068d400446cfec84 Mon Sep 17 00:00:00 2001 From: Jan Malakhovski Date: Thu, 6 Sep 2018 19:40:16 +0000 Subject: [PATCH 2/6] kodi: wrapper: simplify --- pkgs/applications/video/kodi/wrapper.nix | 58 ++++++------------------ 1 file changed, 14 insertions(+), 44 deletions(-) diff --git a/pkgs/applications/video/kodi/wrapper.nix b/pkgs/applications/video/kodi/wrapper.nix index e6d3fbb090fc..27a7a9d34662 100644 --- a/pkgs/applications/video/kodi/wrapper.nix +++ b/pkgs/applications/video/kodi/wrapper.nix @@ -1,54 +1,24 @@ -{ stdenv, lib, makeWrapper, kodi, plugins }: +{ stdenv, lib, makeWrapper, buildEnv, kodi, plugins }: -let +buildEnv { + name = "kodi-with-plugins-${(builtins.parseDrvName kodi.name).version}"; - p = builtins.parseDrvName kodi.name; - -in - -stdenv.mkDerivation { - - name = "kodi-" + p.version; - version = p.version; + paths = [ kodi ] ++ plugins; + pathsToLink = [ "/share" ]; buildInputs = [ makeWrapper ]; - buildCommand = '' - mkdir -p $out/share/kodi/addons - ${stdenv.lib.concatMapStrings - (plugin: "ln -s ${plugin.out - + plugin.kodiPlugin - + "/" + plugin.namespace - } $out/share/kodi/addons/.;") plugins} - $(for plugin in ${kodi}/share/kodi/addons/* + postBuild = '' + mkdir $out/bin + for exe in kodi{,-standalone} do - $(ln -s $plugin/ $out/share/kodi/addons/.) - done) - $(for share in ${kodi}/share/kodi/* - do - $(ln -s $share $out/share/kodi/.) - done) - $(for passthrough in icons xsessions applications - do - ln -s ${kodi}/share/$passthrough $out/share/ - done) - $(for exe in kodi{,-standalone} - do - makeWrapper ${kodi}/bin/$exe $out/bin/$exe \ - --prefix KODI_HOME : $out/share/kodi; - done) + makeWrapper ${kodi}/bin/$exe $out/bin/$exe \ + --prefix KODI_HOME : $out/share/kodi + done ''; - preferLocalBuild = true; - - meta = with kodi.meta; { - inherit license homepage; - description = description - + " (with plugins: " - + lib.concatStrings (lib.intersperse ", " (map (x: ""+x.name) plugins)) - + ")"; - - platforms = stdenv.lib.platforms.linux; + meta = kodi.meta // { + description = kodi.meta.description + + " (with plugins: ${lib.concatMapStringsSep ", " (x: x.name) plugins})"; }; - } From 02557dade2d31be4921f52687db411b3f1137baf Mon Sep 17 00:00:00 2001 From: Jan Malakhovski Date: Thu, 6 Sep 2018 19:40:18 +0000 Subject: [PATCH 3/6] kodi: passthu pythonPackages --- pkgs/applications/video/kodi/default.nix | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/pkgs/applications/video/kodi/default.nix b/pkgs/applications/video/kodi/default.nix index 454665455c51..9272d3c8e269 100644 --- a/pkgs/applications/video/kodi/default.nix +++ b/pkgs/applications/video/kodi/default.nix @@ -1,5 +1,5 @@ { stdenv, lib, fetchFromGitHub, autoconf, automake, libtool, makeWrapper -, pkgconfig, cmake, gnumake, yasm, python2 +, pkgconfig, cmake, gnumake, yasm, python2Packages , libgcrypt, libgpgerror, libunistring , boost, avahi, lame, autoreconfHook , gettext, pcre-cpp, yajl, fribidi, which @@ -119,7 +119,7 @@ in stdenv.mkDerivation rec { buildInputs = [ gnutls libidn libtasn1 nasm p11-kit - libxml2 yasm python2 + libxml2 yasm python2Packages.python boost libmicrohttpd gettext pcre-cpp yajl fribidi libva libdrm openssl gperf tinyxml2 taglib libssh swig jre @@ -187,7 +187,7 @@ in stdenv.mkDerivation rec { postInstall = '' for p in $(ls $out/bin/) ; do wrapProgram $out/bin/$p \ - --prefix PATH ":" "${lib.makeBinPath [ python2 glxinfo xdpyinfo ]}" \ + --prefix PATH ":" "${lib.makeBinPath [ python2Packages.python glxinfo xdpyinfo ]}" \ --prefix LD_LIBRARY_PATH ":" "${lib.makeLibraryPath ([ curl systemd libmad libvdpau libcec libcec_platform rtmpdump libass ] ++ lib.optional nfsSupport libnfs)}" done @@ -200,6 +200,10 @@ in stdenv.mkDerivation rec { installCheckPhase = "$out/bin/kodi --version"; + passthru = { + pythonPackages = python2Packages; + }; + meta = with stdenv.lib; { description = "Media center"; homepage = https://kodi.tv/; From 1d64f70bd75277bd5a69bc9f89c06ece24ed0877 Mon Sep 17 00:00:00 2001 From: Jan Malakhovski Date: Thu, 6 Sep 2018 19:40:19 +0000 Subject: [PATCH 4/6] kodi: wrapper: set PYTHONPATH from plugins --- pkgs/applications/video/kodi/wrapper.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/pkgs/applications/video/kodi/wrapper.nix b/pkgs/applications/video/kodi/wrapper.nix index 27a7a9d34662..d0dc9274a105 100644 --- a/pkgs/applications/video/kodi/wrapper.nix +++ b/pkgs/applications/video/kodi/wrapper.nix @@ -13,6 +13,7 @@ buildEnv { for exe in kodi{,-standalone} do makeWrapper ${kodi}/bin/$exe $out/bin/$exe \ + --prefix PYTHONPATH : ${kodi.pythonPackages.makePythonPath plugins} \ --prefix KODI_HOME : $out/share/kodi done ''; From e883b86c0e894328eb7cb88f287c1c52047d51f1 Mon Sep 17 00:00:00 2001 From: Jan Malakhovski Date: Thu, 6 Sep 2018 19:40:21 +0000 Subject: [PATCH 5/6] kodiPlugins: inline commons.nix --- pkgs/applications/video/kodi/commons.nix | 83 ------------------------ pkgs/applications/video/kodi/plugins.nix | 78 +++++++++++++++++++++- 2 files changed, 76 insertions(+), 85 deletions(-) delete mode 100644 pkgs/applications/video/kodi/commons.nix diff --git a/pkgs/applications/video/kodi/commons.nix b/pkgs/applications/video/kodi/commons.nix deleted file mode 100644 index eff9b7871069..000000000000 --- a/pkgs/applications/video/kodi/commons.nix +++ /dev/null @@ -1,83 +0,0 @@ -{ stdenv, fetchFromGitHub -, cmake, kodiPlain, libcec_platform, tinyxml }: - -rec { - - pluginDir = "/share/kodi/addons"; - - 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 ]; - - }; - - mkKodiAPIPlugin = { plugin, namespace, version, src, meta, sourceDir ? null, ... }: - stdenv.lib.makeOverridable stdenv.mkDerivation rec { - - inherit src meta sourceDir; - - name = "kodi-plugin-${plugin}-${version}"; - - passthru = { - kodiPlugin = pluginDir; - namespace = namespace; - }; - - 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 - ''; - - }; - - mkKodiPlugin = mkKodiAPIPlugin; - - mkKodiABIPlugin = { plugin, namespace, version, src, meta - , extraBuildInputs ? [], sourceDir ? null, ... }: - stdenv.lib.makeOverridable stdenv.mkDerivation rec { - - inherit src meta sourceDir; - - name = "kodi-plugin-${plugin}-${version}"; - - passthru = { - kodiPlugin = pluginDir; - namespace = namespace; - }; - - 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} - ''; - - }; -} diff --git a/pkgs/applications/video/kodi/plugins.nix b/pkgs/applications/video/kodi/plugins.nix index 2ba23e72a2ed..e2e4dd28f8f5 100644 --- a/pkgs/applications/video/kodi/plugins.nix +++ b/pkgs/applications/video/kodi/plugins.nix @@ -1,10 +1,84 @@ { stdenv, callPackage, fetchurl, fetchFromGitHub, unzip +, cmake, kodiPlain, libcec_platform, tinyxml , steam, libusb, pcre-cpp, jsoncpp, libhdhomerun, zlib }: -with (callPackage ./commons.nix {}); - rec { + pluginDir = "/share/kodi/addons"; + + 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, src, meta, sourceDir ? null, ... }: + stdenv.lib.makeOverridable stdenv.mkDerivation rec { + + inherit src meta sourceDir; + + name = "kodi-plugin-${plugin}-${version}"; + + passthru = { + kodiPlugin = pluginDir; + namespace = namespace; + }; + + 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 + ''; + + }; + + mkKodiABIPlugin = { plugin, namespace, version, src, meta + , extraBuildInputs ? [], sourceDir ? null, ... }: + stdenv.lib.makeOverridable stdenv.mkDerivation rec { + + inherit src meta sourceDir; + + name = "kodi-plugin-${plugin}-${version}"; + + passthru = { + kodiPlugin = pluginDir; + namespace = namespace; + }; + + 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} + ''; + + }; + advanced-launcher = mkKodiPlugin rec { plugin = "advanced-launcher"; From 031e1cf674fddd71e998102cdd681ec5211c968a Mon Sep 17 00:00:00 2001 From: Jan Malakhovski Date: Thu, 6 Sep 2018 19:40:22 +0000 Subject: [PATCH 6/6] kodiPlugins: simplify, generalize, implement kodiWithPlugins --- pkgs/applications/video/kodi/plugins.nix | 103 ++++++++++++----------- 1 file changed, 56 insertions(+), 47 deletions(-) diff --git a/pkgs/applications/video/kodi/plugins.nix b/pkgs/applications/video/kodi/plugins.nix index e2e4dd28f8f5..f2ceacdd799f 100644 --- a/pkgs/applications/video/kodi/plugins.nix +++ b/pkgs/applications/video/kodi/plugins.nix @@ -2,10 +2,36 @@ , cmake, kodiPlain, libcec_platform, tinyxml , steam, libusb, pcre-cpp, jsoncpp, libhdhomerun, zlib }: -rec { +with stdenv.lib; + +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"; @@ -21,18 +47,10 @@ rec { buildInputs = [ cmake kodiPlain libcec_platform tinyxml ]; }; - mkKodiPlugin = { plugin, namespace, version, src, meta, sourceDir ? null, ... }: - stdenv.lib.makeOverridable stdenv.mkDerivation rec { - - inherit src meta sourceDir; - + mkKodiPlugin = { plugin, namespace, version, sourceDir ? null, ... }@args: + toKodiPlugin (stdenv.mkDerivation (rec { name = "kodi-plugin-${plugin}-${version}"; - passthru = { - kodiPlugin = pluginDir; - namespace = namespace; - }; - dontStrip = true; installPhase = '' @@ -43,22 +61,12 @@ rec { [ -d ${namespace} ] && sauce=${namespace} cp -R "$sauce/"* $d ''; + } // args)); - }; - - mkKodiABIPlugin = { plugin, namespace, version, src, meta - , extraBuildInputs ? [], sourceDir ? null, ... }: - stdenv.lib.makeOverridable stdenv.mkDerivation rec { - - inherit src meta sourceDir; - + mkKodiABIPlugin = { plugin, namespace, version, extraBuildInputs ? [], ... }@args: + toKodiPlugin (stdenv.mkDerivation (rec { name = "kodi-plugin-${plugin}-${version}"; - passthru = { - kodiPlugin = pluginDir; - namespace = namespace; - }; - dontStrip = true; buildInputs = [ cmake kodiPlain kodi-platform libcec_platform ] @@ -76,8 +84,7 @@ rec { make install ln -s $out/lib/addons/${n}/${n}.so.${version} $out${pluginDir}/${n}/${n}.so.${version} ''; - - }; + } // args)); advanced-launcher = mkKodiPlugin rec { @@ -92,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 = '' @@ -122,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 = '' @@ -149,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 ]; @@ -173,7 +180,7 @@ rec { // (mkController "ps") // (mkController "snes"); - exodus = (mkKodiPlugin rec { + exodus = mkKodiPlugin rec { plugin = "exodus"; namespace = "plugin.video.exodus"; @@ -184,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"; @@ -202,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 ]; @@ -233,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 ]; @@ -257,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 = '' @@ -286,7 +294,7 @@ rec { extraBuildInputs = [ libusb ]; - meta = with stdenv.lib; { + meta = { description = "Binary addon for steam controller."; platforms = platforms.all; maintainers = with maintainers; [ edwtjo ]; @@ -294,7 +302,7 @@ rec { }; - steam-launcher = (mkKodiPlugin rec { + steam-launcher = mkKodiPlugin rec { plugin = "steam-launcher"; namespace = "script.steam.launcher"; @@ -307,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 = '' @@ -319,8 +329,6 @@ rec { ''; maintainers = with maintainers; [ edwtjo ]; }; - }).override { - propagatedBuildInputs = [ steam ]; }; pdfreader = mkKodiPlugin rec { @@ -336,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 ]; @@ -356,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; @@ -378,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; @@ -402,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; @@ -426,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; @@ -434,4 +442,5 @@ rec { license = licenses.cc-by-nc-sa-30; }; }; -} + +}; in self