From 8d1657b463bf088ee24ca5a273f5466ded9af636 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edward=20Tj=C3=B6rnhammar?= Date: Mon, 19 Jan 2015 22:14:36 +0100 Subject: [PATCH 1/3] Migrating the XBMC plugin wrapper and plugins to Kodi. --- pkgs/applications/video/kodi/plugins.nix | 108 +++++++++++++++++++++++ pkgs/applications/video/kodi/wrapper.nix | 53 +++++++++++ pkgs/top-level/all-packages.nix | 22 ++++- 3 files changed, 181 insertions(+), 2 deletions(-) create mode 100644 pkgs/applications/video/kodi/plugins.nix create mode 100644 pkgs/applications/video/kodi/wrapper.nix diff --git a/pkgs/applications/video/kodi/plugins.nix b/pkgs/applications/video/kodi/plugins.nix new file mode 100644 index 000000000000..e38e00bc61f7 --- /dev/null +++ b/pkgs/applications/video/kodi/plugins.nix @@ -0,0 +1,108 @@ +{ stdenv, fetchFromGitHub, kodi }: + +let + + pluginDir = "/lib/kodi/plugin"; + + mkKodiPlugin = { plugin, namespace, version, src, meta, ... }: + stdenv.lib.makeOverridable stdenv.mkDerivation rec { + inherit src meta; + name = "kodi-plugin-${plugin}-${version}"; + passthru = { + kodiPlugin = pluginDir; + namespace = namespace; + }; + dontStrip = true; + installPhase = '' + d=$out${pluginDir}/${namespace} + mkdir -p $d + sauce="." + [ -d ${namespace} ] && sauce=${namespace} + cp -R $sauce/* $d + ''; + }; + +in +{ + + advanced-launcher = mkKodiPlugin rec { + + plugin = "advanced-launcher"; + namespace = "plugin.program.advanced.launcher"; + version = "2.5.8"; + + src = fetchFromGitHub { + owner = "Angelscry"; + repo = namespace; + rev = "bb380b6e8b664246a791f553ddc856cbc60dae1f"; + sha256 = "0g4kk68zjl5rf6mll4g4cywq70s267471dp5r1qp3bpfpzkn0vf2"; + }; + + meta = with stdenv.lib; { + homepage = "http://forum.kodi.tv/showthread.php?tid=85724"; + description = "A program launcher for Kodi"; + longDescription = '' + Advanced Launcher allows you to start any Linux, Windows and + OS X external applications (with command line support or not) + directly from the Kodi GUI. Advanced Launcher also give you + the possibility to edit, download (from Internet resources) + and manage all the meta-data (informations and images) related + to these applications. + ''; + platforms = platforms.all; + maintainers = with maintainers; [ edwtjo ]; + }; + + }; + + genesis = mkKodiPlugin rec { + + plugin = "genesis"; + namespace = "plugin.video.genesis"; + version = "2.4.1"; + + src = fetchFromGitHub { + owner = "lambda81"; + repo = "lambda-addons"; + rev = "1eb1632063e18f3f30e9fdbed2a15cf1e9c05315"; + sha256 = "1gzx0jq4gyhkpdd21a70lhww9djr5dlgyl93b4l7dhgr3hnzxccl"; + }; + + meta = with stdenv.lib; { + homepage = "http://forums.tvaddons.ag/forums/148-lambda-s-kodi-addons"; + description = "The origins of streaming"; + platforms = platforms.all; + maintainers = with maintainers; [ edwtjo ]; + }; + + }; + + svtplay = mkKodiPlugin rec { + + plugin = "svtplay"; + namespace = "plugin.video.svtplay"; + version = "4.0.9"; + + src = fetchFromGitHub { + owner = "nilzen"; + repo = "xbmc-" + plugin; + rev = "29a754e49584d1ca32f0c07b87304669cf266bb0"; + sha256 = "0k7mwaknw4h1jlq7ialbzgxxpb11j8bk29dx2gimp40lvnyw4yhz"; + }; + + meta = with stdenv.lib; { + homepage = "http://forum.kodi.org/showthread.php?tid=67110"; + description = "Watch content from SVT Play"; + longDescription = '' + With this addon you can stream content from SVT Play + (svtplay.se). The plugin fetches the video URL from the SVT + Play website and feeds it to the Kodi video player. HLS (m3u8) + is the preferred video format by the plugin. + ''; + platforms = platforms.all; + maintainers = with maintainers; [ edwtjo ]; + }; + + }; + +} \ No newline at end of file diff --git a/pkgs/applications/video/kodi/wrapper.nix b/pkgs/applications/video/kodi/wrapper.nix new file mode 100644 index 000000000000..9f7a87f9987e --- /dev/null +++ b/pkgs/applications/video/kodi/wrapper.nix @@ -0,0 +1,53 @@ +{ stdenv, lib, makeWrapper, kodi, plugins }: + +let + + p = builtins.parseDrvName kodi.name; + +in + +stdenv.mkDerivation { + + name = "kodi-" + p.version; + version = p.version; + + buildInputs = [ makeWrapper ]; + + buildCommand = '' + mkdir -p $out/share/kodi/addons/packages + ${stdenv.lib.concatMapStrings + (plugin: "ln -s ${plugin.out + + plugin.kodiPlugin + + "/" + plugin.namespace + } $out/share/kodi/addons/.;") plugins} + $(for plugin in ${kodi}/share/kodi/addons/* + 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) + ''; + + preferLocalBuilds = true; + + meta = with kodi.meta; { + inherit license homepage; + description = description + + " (with plugins: " + + lib.concatStrings (lib.intersperse ", " (map (x: ""+x.name) plugins)) + + ")"; + + }; + +} \ No newline at end of file diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 9bcb526f3aeb..527d72b3e2d9 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -11529,6 +11529,16 @@ let ); }; + wrapKodi = { kodi }: import ../applications/video/kodi/wrapper.nix { + inherit stdenv lib makeWrapper kodi; + plugins = let inherit (lib) optional; in with kodiPlugins; + ([] + ++ optional (config.kodi.enableAdvancedLauncher or false) advanced-launcher + ++ optional (config.kodi.enableGenesis or false) genesis + ++ optional (config.kodi.enableSVTPlay or false) svtplay + ); + }; + wxhexeditor = callPackage ../applications/editors/wxhexeditor { }; wxcam = callPackage ../applications/video/wxcam { @@ -11566,12 +11576,20 @@ let xbmc = xbmcPlain; }; - kodi = callPackage ../applications/video/kodi { }; + kodiPlain = callPackage ../applications/video/kodi { }; + + kodiPlugins = recurseIntoAttrs (callPackage ../applications/video/kodi/plugins.nix { + kodi = kodiPlain; + }); + + kodi = wrapKodi { + kodi = kodiPlain; + }; xbmc-retroarch-advanced-launchers = callPackage ../misc/emulators/retroarch/xbmc-advanced-launchers.nix { cores = retroArchCores; - }; + }; xca = callPackage ../applications/misc/xca { }; From 5b1c9417a82489a9ff9fdf2369b187cd4ee34e50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edward=20Tj=C3=B6rnhammar?= Date: Mon, 19 Jan 2015 22:14:36 +0100 Subject: [PATCH 2/3] Add Kodi desktop-manager --- .../services/x11/desktop-managers/default.nix | 2 +- .../services/x11/desktop-managers/kodi.nix | 31 +++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 nixos/modules/services/x11/desktop-managers/kodi.nix diff --git a/nixos/modules/services/x11/desktop-managers/default.nix b/nixos/modules/services/x11/desktop-managers/default.nix index bffbb56e6816..2e6a3dd8a3c2 100644 --- a/nixos/modules/services/x11/desktop-managers/default.nix +++ b/nixos/modules/services/x11/desktop-managers/default.nix @@ -19,7 +19,7 @@ in # E.g., if KDE is enabled, it supersedes xterm. imports = [ ./none.nix ./xterm.nix ./xfce.nix ./kde4.nix - ./e19.nix ./gnome3.nix ./xbmc.nix + ./e19.nix ./gnome3.nix ./xbmc.nix ./kodi.nix ]; options = { diff --git a/nixos/modules/services/x11/desktop-managers/kodi.nix b/nixos/modules/services/x11/desktop-managers/kodi.nix new file mode 100644 index 000000000000..1e30308a5139 --- /dev/null +++ b/nixos/modules/services/x11/desktop-managers/kodi.nix @@ -0,0 +1,31 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + cfg = config.services.xserver.desktopManager.kodi; +in + +{ + options = { + services.xserver.desktopManager.kodi = { + enable = mkOption { + default = false; + example = true; + description = "Enable the kodi multimedia center."; + }; + }; + }; + + config = mkIf cfg.enable { + services.xserver.desktopManager.session = [{ + name = "kodi"; + start = '' + ${pkgs.kodi}/bin/kodi --lircdev /var/run/lirc/lircd --standalone & + waitPID=$! + ''; + }]; + + environment.systemPackages = [ pkgs.kodi ]; + }; +} \ No newline at end of file From 3a321906d17b230a3f5803e5bbc6bb6e4ff4e2cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edward=20Tj=C3=B6rnhammar?= Date: Mon, 19 Jan 2015 22:14:37 +0100 Subject: [PATCH 3/3] Add Kodi retroarch launchers --- .../retroarch/kodi-advanced-launchers.nix | 39 +++++++++++++++++++ pkgs/top-level/all-packages.nix | 5 +++ 2 files changed, 44 insertions(+) create mode 100644 pkgs/misc/emulators/retroarch/kodi-advanced-launchers.nix diff --git a/pkgs/misc/emulators/retroarch/kodi-advanced-launchers.nix b/pkgs/misc/emulators/retroarch/kodi-advanced-launchers.nix new file mode 100644 index 000000000000..38b8e27db7d9 --- /dev/null +++ b/pkgs/misc/emulators/retroarch/kodi-advanced-launchers.nix @@ -0,0 +1,39 @@ +{ stdenv, pkgs, cores }: + +assert cores != []; + +with pkgs.lib; + +let + + script = exec: '' + #!${stdenv.shell} + nohup sh -c "sleep 1 && pkill -SIGSTOP kodi" & + nohup sh -c "${exec} '$@' -f;pkill -SIGCONT kodi" + ''; + scriptSh = exec: pkgs.writeScript ("kodi-"+exec.name) (script exec.path); + execs = map (core: rec { name = core.core; path = core+"/bin/retroarch-"+name;}) cores; + +in + +stdenv.mkDerivation rec { + name = "kodi-retroarch-advanced-launchers-${version}"; + version = "0.2"; + + dontBuild = true; + + buildCommand = '' + mkdir -p $out/bin + ${stdenv.lib.concatMapStrings (exec: "ln -s ${scriptSh exec} $out/bin/kodi-${exec.name};") execs} + ''; + + meta = { + description = "Kodi retroarch advanced launchers"; + longDescription = '' + These retroarch launchers are intended to be used with + anglescry advanced launcher for Kodi since device input is + caught by both Kodi and the retroarch process. + ''; + license = stdenv.lib.licenses.gpl3; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 527d72b3e2d9..db8bc95c79ef 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -11591,6 +11591,11 @@ let cores = retroArchCores; }; + kodi-retroarch-advanced-launchers = + callPackage ../misc/emulators/retroarch/kodi-advanced-launchers.nix { + cores = retroArchCores; + }; + xca = callPackage ../applications/misc/xca { }; xcalib = callPackage ../tools/X11/xcalib { };