3
0
Fork 0
forked from mirrors/nixpkgs
nixpkgs/pkgs/applications/video/kodi/wrapper.nix

46 lines
1.7 KiB
Nix
Raw Normal View History

2021-07-21 00:58:09 +01:00
{ lib, makeWrapper, buildEnv, kodi, addons, callPackage }:
let
2021-07-21 00:58:09 +01:00
kodiPackages = callPackage ../../../top-level/kodi-packages.nix { inherit kodi; };
# linux distros are supposed to provide pillow and pycryptodome
2021-07-21 00:58:09 +01:00
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";
2021-03-10 01:53:45 +00:00
paths = [ kodi ] ++ addons;
2018-09-06 20:40:16 +01:00
pathsToLink = [ "/share" ];
2021-11-07 21:08:13 +00:00
nativeBuildInputs = [ makeWrapper ];
2018-09-06 20:40:16 +01:00
postBuild = ''
mkdir $out/bin
for exe in kodi{,-standalone}
do
2018-09-06 20:40:16 +01:00
makeWrapper ${kodi}/bin/$exe $out/bin/$exe \
2021-07-21 00:58:09 +01:00
--prefix PYTHONPATH : ${requiredPythonPath}:${additionalPythonPath} \
--prefix KODI_HOME : $out/share/kodi \
--prefix LD_LIBRARY_PATH ":" "${lib.makeLibraryPath
2021-01-15 05:42:41 +00:00
(lib.concatMap
2021-03-10 01:53:45 +00:00
(plugin: plugin.extraRuntimeDependencies or []) addons)}"
2018-09-06 20:40:16 +01:00
done
# makeWrapper just created webinterface.default as a symlink. However,
# kodi's webserver carefully refuses to follow symlinks, so we need to copy
# these assets instead.
rm $out/share/kodi/addons/webinterface.default
cp -r ${kodi}/share/kodi/addons/webinterface.default/ $out/share/kodi/addons/webinterface.default
'';
}