diff options
author | Bjørn Forsman <bjorn.forsman@gmail.com> | 2023-07-19 13:11:14 +0200 |
---|---|---|
committer | Bjørn Forsman <bjorn.forsman@gmail.com> | 2023-07-19 14:11:34 +0200 |
commit | 801cc447659ee28e15b521f08e84df9c3d5f1bb6 (patch) | |
tree | f1f38f3b870610edd7e84089db52c2a868b8c078 | |
parent | 7120535c321c192e3ffec550a271c9f02da9830c (diff) |
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).
-rw-r--r-- | pkgs/applications/emulators/retroarch/wrapper.nix | 18 | ||||
-rw-r--r-- | pkgs/top-level/all-packages.nix | 4 |
2 files changed, 17 insertions, 5 deletions
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}"; diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index cf4fcc3447419..786c227cd7dec 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -2642,9 +2642,9 @@ with pkgs; (builtins.attrValues libretro); }; - wrapRetroArch = { retroarch }: + wrapRetroArch = { retroarch, settings ? {} }: callPackage ../applications/emulators/retroarch/wrapper.nix - { inherit retroarch; }; + { inherit retroarch settings; }; retroarch = wrapRetroArch { retroarch = retroarchBare.override { |