about summary refs log tree commit diff
path: root/pkgs/applications/emulators/retroarch/wrapper.nix
blob: 535cd40db6c341c5b10d0bde986c59e754ad534a (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
{ stdenv, lib, makeWrapper, retroarch, cores ? [ ] }:

stdenv.mkDerivation {
  pname = "retroarch";
  version = lib.getVersion retroarch;

  nativeBuildInputs = [ makeWrapper ];

  buildCommand = ''
    mkdir -p $out/lib
    for coreDir in $cores; do
      ln -s $coreDir/* $out/lib/.
    done

    ln -s -t $out ${retroarch}/share

    if [ -d ${retroarch}/Applications ]; then
      ln -s -t $out ${retroarch}/Applications
    fi

    makeWrapper ${retroarch}/bin/retroarch $out/bin/retroarch \
      --suffix-each LD_LIBRARY_PATH ':' "$cores" \
      --add-flags "-L $out/lib/" \
  '';

  cores = map (x: x + x.libretroCore) cores;
  preferLocalBuild = true;

  meta = with retroarch.meta; {
    inherit changelog description homepage license maintainers platforms;
    longDescription = ''
      RetroArch is the reference frontend for the libretro API.

      The following cores are included:
      ${lib.concatStringsSep "\n" (map (x: "  - ${x.name}") cores)}
    '';
    # FIXME: exit with error on macOS:
    # No Info.plist file in application bundle or no NSPrincipalClass in the Info.plist file, exiting
    broken = stdenv.isDarwin;
  };
}