about summary refs log tree commit diff
path: root/pkgs/applications/emulators/retroarch/wrapper.nix
diff options
context:
space:
mode:
authorThiago Kenji Okada <thiagokokada@gmail.com>2022-10-28 23:52:09 +0100
committerThiago Kenji Okada <thiagokokada@gmail.com>2022-10-29 12:36:58 +0100
commit784c363bd0fad7249e793c808e3883ff59d936ab (patch)
treef1275ec52774f583384a11d233af860085594ead /pkgs/applications/emulators/retroarch/wrapper.nix
parenteb2992e8f84494257ef6ef6682fa1456117e3d71 (diff)
retroarch: use libretro-core-info, simplify patch
A smaller patch should make easier to bump this package in the future.
Diffstat (limited to 'pkgs/applications/emulators/retroarch/wrapper.nix')
-rw-r--r--pkgs/applications/emulators/retroarch/wrapper.nix16
1 files changed, 9 insertions, 7 deletions
diff --git a/pkgs/applications/emulators/retroarch/wrapper.nix b/pkgs/applications/emulators/retroarch/wrapper.nix
index 7ce75b22ba47b..4136d263eac4c 100644
--- a/pkgs/applications/emulators/retroarch/wrapper.nix
+++ b/pkgs/applications/emulators/retroarch/wrapper.nix
@@ -3,14 +3,17 @@
 , 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 (corePath: [ "--add-flags" "-L ${placeholder "out" + corePath}" ]) coresPath));
+      (map (p: [ "--add-flags" "-L ${placeholder "out" + p}" ]) coresPath));
 in
 symlinkJoin {
   name = "retroarch-with-cores-${lib.getVersion retroarch}";
@@ -26,11 +29,10 @@ symlinkJoin {
 
   postBuild = ''
     # remove core specific binaries
-    find $out/bin -name 'retroarch-*' -delete
-    # wrapProgram can't operate on symlinks
-    rm $out/bin/retroarch
-    makeWrapper ${retroarch}/bin/retroarch $out/bin/retroarch \
-      ${wrapperArgs}
+    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; {
@@ -39,7 +41,7 @@ symlinkJoin {
       RetroArch is the reference frontend for the libretro API.
     ''
     + lib.optionalString (cores != [ ]) ''
-      The following cores are included: ${lib.concatStringsSep ", " (map (x: x.core) cores)}
+      The following cores are included: ${lib.concatStringsSep ", " (map (c: c.core) cores)}
     '';
     mainProgram = "retroarch";
   };