about summary refs log tree commit diff
path: root/pkgs/applications/emulators
diff options
context:
space:
mode:
authorThiago Kenji Okada <thiagokokada@gmail.com>2023-07-19 14:12:24 +0000
committerGitHub <noreply@github.com>2023-07-19 14:12:24 +0000
commitda865b2b9e32d94f33c6862465bfa0e2f132a87e (patch)
tree8a423870f5e39a3a3c3663dd65433a326ff273e1 /pkgs/applications/emulators
parentf119d4c1d86ea7fb91171313a7523810926df076 (diff)
parent9d793505b9e2b5d58f50e60ebfa74d7bd0665cc4 (diff)
Merge pull request #244339 from bjornfor/retroarch-auto-detect-joypads
retroarch: auto-detect joypads
Diffstat (limited to 'pkgs/applications/emulators')
-rw-r--r--pkgs/applications/emulators/retroarch/retroarch-joypad-autoconfig.nix28
-rw-r--r--pkgs/applications/emulators/retroarch/wrapper.nix18
2 files changed, 43 insertions, 3 deletions
diff --git a/pkgs/applications/emulators/retroarch/retroarch-joypad-autoconfig.nix b/pkgs/applications/emulators/retroarch/retroarch-joypad-autoconfig.nix
new file mode 100644
index 0000000000000..92ba7f20c8b36
--- /dev/null
+++ b/pkgs/applications/emulators/retroarch/retroarch-joypad-autoconfig.nix
@@ -0,0 +1,28 @@
+{ lib
+, stdenvNoCC
+, fetchFromGitHub
+}:
+
+stdenvNoCC.mkDerivation rec {
+  pname = "retroarch-joypad-autoconfig";
+  version = "1.15.0";
+
+  src = fetchFromGitHub {
+    owner = "libretro";
+    repo = "retroarch-joypad-autoconfig";
+    rev = "v${version}";
+    hash = "sha256-/F2Y08uDA/pIIeLiLfOQfGVjX2pkuOqPourlx2RbZ28=";
+  };
+
+  makeFlags = [
+    "PREFIX=$(out)"
+  ];
+
+  meta = with lib; {
+    description = "Joypad autoconfig files";
+    homepage = "https://www.libretro.com/";
+    license = licenses.mit;
+    maintainers = with maintainers; teams.libretro.members ++ [ ];
+    platforms = platforms.all;
+  };
+}
diff --git a/pkgs/applications/emulators/retroarch/wrapper.nix b/pkgs/applications/emulators/retroarch/wrapper.nix
index afef0bef8a487..4698bbe5bbedb 100644
--- a/pkgs/applications/emulators/retroarch/wrapper.nix
+++ b/pkgs/applications/emulators/retroarch/wrapper.nix
@@ -3,16 +3,28 @@
 , 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));
+  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}";