2022-10-30 15:09:59 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, makeWrapper
|
|
|
|
, retroarch
|
|
|
|
, symlinkJoin
|
|
|
|
, writeTextDir
|
|
|
|
, cores ? [ ]
|
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
|
|
|
# All cores should be located in the same path after symlinkJoin,
|
|
|
|
# but let's be safe here
|
|
|
|
coresPath = lib.lists.unique (map (c: c.libretroCore) cores);
|
|
|
|
wrapperArgs = lib.strings.escapeShellArgs
|
|
|
|
(lib.lists.flatten
|
|
|
|
(map (p: [ "--add-flags" "-L ${placeholder "out" + p}" ]) coresPath));
|
|
|
|
in
|
|
|
|
symlinkJoin {
|
|
|
|
name = "retroarch-with-cores-${lib.getVersion retroarch}";
|
|
|
|
|
|
|
|
paths = [ retroarch ] ++ cores;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-03-09 03:18:52 +00:00
|
|
|
nativeBuildInputs = [ makeWrapper ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-10-30 15:09:59 +00:00
|
|
|
passthru = {
|
|
|
|
inherit cores;
|
|
|
|
unwrapped = retroarch;
|
|
|
|
};
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-10-30 15:09:59 +00:00
|
|
|
postBuild = ''
|
|
|
|
# remove core specific binaries
|
|
|
|
find $out/bin -name 'retroarch-*' -type l -delete
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-10-30 15:09:59 +00:00
|
|
|
# wrap binary to load cores from the proper location(s)
|
|
|
|
wrapProgram $out/bin/retroarch ${wrapperArgs}
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
meta = with retroarch.meta; {
|
2022-02-21 08:47:16 +00:00
|
|
|
inherit changelog description homepage license maintainers platforms;
|
2022-04-15 01:41:22 +00:00
|
|
|
longDescription = ''
|
|
|
|
RetroArch is the reference frontend for the libretro API.
|
2022-10-30 15:09:59 +00:00
|
|
|
''
|
|
|
|
+ lib.optionalString (cores != [ ]) ''
|
|
|
|
The following cores are included: ${lib.concatStringsSep ", " (map (c: c.core) cores)}
|
2022-04-15 01:41:22 +00:00
|
|
|
'';
|
2022-10-30 15:09:59 +00:00
|
|
|
mainProgram = "retroarch";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|