retroarch: add support for declarative settings

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).

+17 -5
+15 -3
pkgs/applications/emulators/retroarch/wrapper.nix
··· 3 3 , makeWrapper 4 4 , retroarch 5 5 , symlinkJoin 6 + , runCommand 6 7 , cores ? [ ] 8 + , settings ? { } 7 9 }: 8 10 9 11 let 12 + settingsPath = runCommand "declarative-retroarch.cfg" 13 + { 14 + value = lib.concatStringsSep "\n" (lib.mapAttrsToList (n: v: "${n} = \"${v}\"") settings); 15 + passAsFile = [ "value" ]; 16 + } 17 + '' 18 + cp "$valuePath" "$out" 19 + ''; 20 + 10 21 # All cores should be located in the same path after symlinkJoin, 11 22 # but let's be safe here 12 23 coresPath = lib.lists.unique (map (c: c.libretroCore) cores); 13 - wrapperArgs = lib.strings.escapeShellArgs 14 - (lib.lists.flatten 15 - (map (p: [ "--add-flags" "-L ${placeholder "out" + p}" ]) coresPath)); 24 + wrapperArgs = lib.strings.escapeShellArgs ( 25 + (lib.lists.flatten (map (p: [ "--add-flags" "-L ${placeholder "out" + p}" ]) coresPath)) 26 + ++ [ "--add-flags" "--appendconfig=${settingsPath}" ] 27 + ); 16 28 in 17 29 symlinkJoin { 18 30 name = "retroarch-with-cores-${lib.getVersion retroarch}";
+2 -2
pkgs/top-level/all-packages.nix
··· 2642 2642 (builtins.attrValues libretro); 2643 2643 }; 2644 2644 2645 - wrapRetroArch = { retroarch }: 2645 + wrapRetroArch = { retroarch, settings ? {} }: 2646 2646 callPackage ../applications/emulators/retroarch/wrapper.nix 2647 - { inherit retroarch; }; 2647 + { inherit retroarch settings; }; 2648 2648 2649 2649 retroarch = wrapRetroArch { 2650 2650 retroarch = retroarchBare.override {