nixpkgs/pkgs/applications/video/kodi/wrapper.nix
Jeremy Fleischman cb720edb7d
kodi: More robust handling of kodi webserver assets
This adds a backport of
a6dedce7ba
to Kodi 19.4 Matrix. This can be removed once a new release of Kodi comes
out and we upgrade to it.

What's nice about this approach is that it doesn't special case
webinterface.default. I've never actually tried using a non-default web
interface with Kodi, but I bet it wouldn't have worked before this
change, and I think it would work after this change =)

See and
https://github.com/NixOS/nixpkgs/pull/152675#issuecomment-1003442175 and
https://forum.kodi.tv/showthread.php?tid=366338&pid=3079493 for some
discussion about this approach.
2022-04-07 21:52:16 -07:00

39 lines
1.4 KiB
Nix

{ lib, makeWrapper, buildEnv, kodi, addons, callPackage }:
let
kodiPackages = callPackage ../../../top-level/kodi-packages.nix { inherit kodi; };
# linux distros are supposed to provide pillow and pycryptodome
requiredPythonPath = with kodi.pythonPackages; makePythonPath ([ pillow pycryptodome ]);
# each kodi addon can potentially export a python module which should be included in PYTHONPATH
# see any addon which supplies `passthru.pythonPath` and the corresponding entry in the addons `addon.xml`
# eg. `<extension point="xbmc.python.module" library="lib" />` -> pythonPath = "lib";
additionalPythonPath =
let
addonsWithPythonPath = lib.filter (addon: addon ? pythonPath) addons;
in
lib.concatMapStringsSep ":" (addon: "${addon}${kodiPackages.addonDir}/${addon.namespace}/${addon.pythonPath}") addonsWithPythonPath;
in
buildEnv {
name = "${kodi.name}-env";
paths = [ kodi ] ++ addons;
pathsToLink = [ "/share" ];
nativeBuildInputs = [ makeWrapper ];
postBuild = ''
mkdir $out/bin
for exe in kodi{,-standalone}
do
makeWrapper ${kodi}/bin/$exe $out/bin/$exe \
--prefix PYTHONPATH : ${requiredPythonPath}:${additionalPythonPath} \
--prefix KODI_HOME : $out/share/kodi \
--prefix LD_LIBRARY_PATH ":" "${lib.makeLibraryPath
(lib.concatMap
(plugin: plugin.extraRuntimeDependencies or []) addons)}"
done
'';
}