about summary refs log tree commit diff
path: root/nixpkgs/pkgs/misc/emulators/retroarch/kodi-advanced-launchers.nix
blob: ee97e6f7493cb9eda6d39a07e67900f41890a87e (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
{ stdenv, pkgs, lib, cores, runtimeShell }:

assert cores != [];

let

  script = exec: ''
    #!${runtimeShell}
    nohup sh -c "pkill -SIGTSTP kodi" &
    # https://forum.kodi.tv/showthread.php?tid=185074&pid=1622750#pid1622750
    nohup sh -c "sleep 10 && ${exec} '$@' -f;pkill -SIGCONT kodi"
  '';
  scriptSh = exec: pkgs.writeScript ("kodi-"+exec.name) (script exec.path);
  execs = map (core: rec { name = core.core; path = core+"/bin/retroarch-"+name;}) cores;

in

stdenv.mkDerivation {
  pname = "kodi-retroarch-advanced-launchers";
  version = "0.2";

  dontBuild = true;

  buildCommand = ''
    mkdir -p $out/bin
    ${lib.concatMapStrings (exec: "ln -s ${scriptSh exec} $out/bin/kodi-${exec.name};") execs}
  '';

  meta = {
    description = "Kodi retroarch advanced launchers";
    longDescription = ''
      These retroarch launchers are intended to be used with
      advanced (emulation) launcher for Kodi since device input is
      otherwise caught by both Kodi and the retroarch process.
    '';
    license = lib.licenses.gpl3;
  };
}