Files
nixpkgs/pkgs/applications/video/kodi/wrapper.nix
Philippe Hürlimann 7d0201dfa6 kodi: use passthru packages in withPackages
Previously kodi.withPackages constructed its own kodiPackages set
instead of using the one exposed through kodi.passthru.packages,
preventing the use of overridden kodi packages in kodi.withPackages.

This change package overrides such that they are observed by both addon
selection and wrapper path construction.
2026-04-30 12:02:11 +02:00

55 lines
1.4 KiB
Nix

{
lib,
makeWrapper,
buildEnv,
kodi,
addons,
}:
let
# 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}${kodi.packages.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
'';
meta = {
inherit (kodi.meta) mainProgram;
};
}