summary refs log tree commit diff
path: root/pkgs/misc/emulators/retroarch/wrapper.nix
blob: 58d41699854ce38334d4f70ff2a23ad662aedaf5 (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
{ stdenv, lib, makeWrapper, retroarch, cores }:

let

  p = builtins.parseDrvName retroarch.name;

in

stdenv.mkDerivation {
  name = "retroarch-" + p.version;
  version = p.version;

  buildInputs = [ makeWrapper ];

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

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

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

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

  meta = with retroarch.meta; {
    inherit license homepage platforms maintainers;
    description = description
                  + " (with cores: "
                  + lib.concatStrings (lib.intersperse ", " (map (x: ""+x.name) cores))
                  + ")";
  };
}