summary refs log tree commit diff
path: root/pkgs/applications/video/kodi/wrapper.nix
blob: 6bec8f9c8912e24776dd67ca72c470cabb3f3d1b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
{ stdenv, lib, makeWrapper, buildEnv, kodi, plugins }:

let
  drvName = builtins.parseDrvName kodi.name;
in buildEnv {
  name = "${drvName.name}-with-plugins-${drvName.version}";

  paths = [ kodi ] ++ plugins;
  pathsToLink = [ "/share" ];

  buildInputs = [ makeWrapper ];

  postBuild = ''
    mkdir $out/bin
    for exe in kodi{,-standalone}
    do
      makeWrapper ${kodi}/bin/$exe $out/bin/$exe \
        --prefix PYTHONPATH : ${kodi.pythonPackages.makePythonPath plugins} \
        --prefix KODI_HOME : $out/share/kodi \
        --prefix LD_LIBRARY_PATH ":" "${lib.makeLibraryPath
          (lib.concatMap
            (plugin: plugin.extraRuntimeDependencies or []) plugins)}"
    done
  '';

  meta = kodi.meta // {
    description = kodi.meta.description
                + " (with plugins: ${lib.concatMapStringsSep ", " (x: x.name) plugins})";
  };
}