1 { lib, makeWrapper, buildEnv, kodi, addons, callPackage }:
4 kodiPackages = callPackage ../../../top-level/kodi-packages.nix { inherit kodi; };
6 # linux distros are supposed to provide pillow and pycryptodome
7 requiredPythonPath = with kodi.pythonPackages; makePythonPath ([ pillow pycryptodome ]);
9 # each kodi addon can potentially export a python module which should be included in PYTHONPATH
10 # see any addon which supplies `passthru.pythonPath` and the corresponding entry in the addons `addon.xml`
11 # eg. `<extension point="xbmc.python.module" library="lib" />` -> pythonPath = "lib";
12 additionalPythonPath =
14 addonsWithPythonPath = lib.filter (addon: addon ? pythonPath) addons;
16 lib.concatMapStringsSep ":" (addon: "${addon}${kodiPackages.addonDir}/${addon.namespace}/${addon.pythonPath}") addonsWithPythonPath;
20 name = "${kodi.name}-env";
22 paths = [ kodi ] ++ addons;
23 pathsToLink = [ "/share" ];
25 nativeBuildInputs = [ makeWrapper ];
29 for exe in kodi{,-standalone}
31 makeWrapper ${kodi}/bin/$exe $out/bin/$exe \
32 --prefix PYTHONPATH : ${requiredPythonPath}:${additionalPythonPath} \
33 --prefix KODI_HOME : $out/share/kodi \
34 --prefix LD_LIBRARY_PATH ":" "${lib.makeLibraryPath
36 (plugin: plugin.extraRuntimeDependencies or []) addons)}"