summaryrefslogtreecommitdiffstats
path: root/pkgs/applications/video/kodi/build-kodi-binary-addon.nix
blob: 894a476540cc7d07e66594ef6d33e102444365d2 (plain)
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
55
56
57
58
59
60
61
62
63
64
65
66
{
  stdenv,
  toKodiAddon,
  addonDir,
  cmake,
  kodi,
  kodi-platform,
  libcec_platform,
}:
{
  name ? "${attrs.pname}-${attrs.version}",
  namespace,
  version,
  extraNativeBuildInputs ? [ ],
  extraBuildInputs ? [ ],
  extraRuntimeDependencies ? [ ],
  extraCMakeFlags ? [ ],
  extraInstallPhase ? "",
  ...
}@attrs:
toKodiAddon (
  stdenv.mkDerivation (
    {
      name = "kodi-" + name;

      dontStrip = true;

      nativeBuildInputs = [ cmake ] ++ extraNativeBuildInputs;
      buildInputs = [
        kodi
        kodi-platform
        libcec_platform
      ]
      ++ extraBuildInputs;

      inherit extraRuntimeDependencies;

      # disables check ensuring install prefix is that of kodi
      cmakeFlags = [
        "-DOVERRIDE_PATHS=1"
      ]
      ++ extraCMakeFlags;

      # kodi checks for addon .so libs existence in the addon folder (share/...)
      # and the non-wrapped kodi lib/... folder before even trying to dlopen
      # them. Symlinking .so, as setting LD_LIBRARY_PATH is of no use
      installPhase =
        let
          n = namespace;
        in
        ''
          runHook preInstall

          make install

          [[ -f $out/lib/addons/${n}/${n}.so ]] && ln -s $out/lib/addons/${n}/${n}.so $out${addonDir}/${n}/${n}.so || true
          [[ -f $out/lib/addons/${n}/${n}.so.${version} ]] && ln -s $out/lib/addons/${n}/${n}.so.${version} $out${addonDir}/${n}/${n}.so.${version} || true

          ${extraInstallPhase}

          runHook postInstall
        '';
    }
    // attrs
  )
)