summary refs log tree commit diff
path: root/pkgs/applications/video/kodi/wrapper.nix
blob: efd0f257ca0138e467864a416f7409a19db64160 (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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
{ stdenv, lib, makeWrapper, kodi, plugins }:

let

  p = builtins.parseDrvName kodi.name;

in

stdenv.mkDerivation {

  name = "kodi-" + p.version;
  version = p.version;

  buildInputs = [ makeWrapper ];

  buildCommand = ''
    mkdir -p $out/share/kodi/addons
    ${stdenv.lib.concatMapStrings
        (plugin: "ln -s ${plugin.out
                            + plugin.kodiPlugin
                            + "/" + plugin.namespace
                          } $out/share/kodi/addons/.;") plugins}
    $(for plugin in ${kodi}/share/kodi/addons/*
    do
      $(ln -s $plugin/ $out/share/kodi/addons/.)
    done)
    $(for share in ${kodi}/share/kodi/*
    do
      $(ln -s $share $out/share/kodi/.)
    done)
    $(for passthrough in icons xsessions applications
    do
      ln -s ${kodi}/share/$passthrough $out/share/
    done)
    $(for exe in kodi{,-standalone}
    do
    makeWrapper ${kodi}/bin/$exe $out/bin/$exe \
      --prefix KODI_HOME : $out/share/kodi;
    done)
  '';

  preferLocalBuilds = true;

  meta = with kodi.meta; {
    inherit license homepage;
    description = description
                + " (with plugins: "
                + lib.concatStrings (lib.intersperse ", " (map (x: ""+x.name) plugins))
                + ")";

    platforms = stdenv.lib.platforms.linux;
  };

}