mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-12-29 09:04:17 +00:00
801cc44765
Add a new optional 'settings' attrset to the wrapper derivation, which gets serialized to a file and passed to RetroArch as --appendconfig= at runtime. This allows overriding settings from ~/.config/retroarch/retroarch.cfg (which initially gets created as a dump of all internal retroarch settings -- stateful and messy).
60 lines
1.5 KiB
Nix
60 lines
1.5 KiB
Nix
{ lib
|
|
, stdenv
|
|
, makeWrapper
|
|
, retroarch
|
|
, symlinkJoin
|
|
, runCommand
|
|
, cores ? [ ]
|
|
, settings ? { }
|
|
}:
|
|
|
|
let
|
|
settingsPath = runCommand "declarative-retroarch.cfg"
|
|
{
|
|
value = lib.concatStringsSep "\n" (lib.mapAttrsToList (n: v: "${n} = \"${v}\"") settings);
|
|
passAsFile = [ "value" ];
|
|
}
|
|
''
|
|
cp "$valuePath" "$out"
|
|
'';
|
|
|
|
# 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))
|
|
++ [ "--add-flags" "--appendconfig=${settingsPath}" ]
|
|
);
|
|
in
|
|
symlinkJoin {
|
|
name = "retroarch-with-cores-${lib.getVersion retroarch}";
|
|
|
|
paths = [ retroarch ] ++ cores;
|
|
|
|
nativeBuildInputs = [ makeWrapper ];
|
|
|
|
passthru = {
|
|
inherit cores;
|
|
unwrapped = retroarch;
|
|
};
|
|
|
|
postBuild = ''
|
|
# remove core specific binaries
|
|
find $out/bin -name 'retroarch-*' -type l -delete
|
|
|
|
# wrap binary to load cores from the proper location(s)
|
|
wrapProgram $out/bin/retroarch ${wrapperArgs}
|
|
'';
|
|
|
|
meta = with retroarch.meta; {
|
|
inherit changelog description homepage license maintainers platforms;
|
|
longDescription = ''
|
|
RetroArch is the reference frontend for the libretro API.
|
|
''
|
|
+ lib.optionalString (cores != [ ]) ''
|
|
The following cores are included: ${lib.concatStringsSep ", " (map (c: c.core) cores)}
|
|
'';
|
|
mainProgram = "retroarch";
|
|
};
|
|
}
|