2021-07-21 01:58:09 +02:00
|
|
|
{ lib, makeWrapper, buildEnv, kodi, addons, callPackage }:
|
2015-01-19 22:14:36 +01:00
|
|
|
|
2021-03-16 01:36:42 +01:00
|
|
|
let
|
2021-07-21 01:58:09 +02:00
|
|
|
kodiPackages = callPackage ../../../top-level/kodi-packages.nix { inherit kodi; };
|
|
|
|
|
2021-03-16 01:36:42 +01:00
|
|
|
# linux distros are supposed to provide pillow and pycryptodome
|
2021-07-21 01:58:09 +02: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;
|
2021-03-16 01:36:42 +01:00
|
|
|
in
|
|
|
|
|
2021-03-10 14:16:10 +01:00
|
|
|
buildEnv {
|
|
|
|
name = "${kodi.name}-env";
|
2015-01-19 22:14:36 +01:00
|
|
|
|
2021-03-10 02:53:45 +01:00
|
|
|
paths = [ kodi ] ++ addons;
|
2018-09-06 21:40:16 +02:00
|
|
|
pathsToLink = [ "/share" ];
|
2015-01-19 22:14:36 +01:00
|
|
|
|
|
|
|
buildInputs = [ makeWrapper ];
|
|
|
|
|
2018-09-06 21:40:16 +02:00
|
|
|
postBuild = ''
|
|
|
|
mkdir $out/bin
|
|
|
|
for exe in kodi{,-standalone}
|
2015-01-19 22:14:36 +01:00
|
|
|
do
|
2018-09-06 21:40:16 +02:00
|
|
|
makeWrapper ${kodi}/bin/$exe $out/bin/$exe \
|
2021-07-21 01:58:09 +02:00
|
|
|
--prefix PYTHONPATH : ${requiredPythonPath}:${additionalPythonPath} \
|
2018-10-29 21:23:17 +01:00
|
|
|
--prefix KODI_HOME : $out/share/kodi \
|
|
|
|
--prefix LD_LIBRARY_PATH ":" "${lib.makeLibraryPath
|
2021-01-15 06:42:41 +01:00
|
|
|
(lib.concatMap
|
2021-03-10 02:53:45 +01:00
|
|
|
(plugin: plugin.extraRuntimeDependencies or []) addons)}"
|
2018-09-06 21:40:16 +02:00
|
|
|
done
|
2015-01-19 22:14:36 +01:00
|
|
|
'';
|
2015-11-30 23:00:09 +01:00
|
|
|
}
|