mirror of
https://github.com/NixOS/nixpkgs.git
synced 2026-12-04 20:00:10 +00:00
retroarch: preserve cores directory when closing content (#588627)
This commit is contained in:
@@ -1621,6 +1621,7 @@ in
|
||||
restic = runTest ./restic.nix;
|
||||
restic-rest-server = runTest ./restic-rest-server.nix;
|
||||
retroarch = runTest ./retroarch.nix;
|
||||
retroarch-wrapper = runTest ./retroarch-wrapper.nix;
|
||||
ringboard = runTest ./ringboard.nix;
|
||||
rke2 = import ./rancher {
|
||||
inherit lib pkgs;
|
||||
|
||||
68
nixos/tests/retroarch-wrapper.nix
Normal file
68
nixos/tests/retroarch-wrapper.nix
Normal file
@@ -0,0 +1,68 @@
|
||||
{ pkgs, ... }:
|
||||
|
||||
let
|
||||
package = pkgs.retroarch-bare.wrapper {
|
||||
cores = [ pkgs.libretro.twenty-fortyeight ];
|
||||
settings = {
|
||||
rgui_config_directory = "/tmp/overrides";
|
||||
video_driver = "sdl2";
|
||||
input_driver = "sdl2";
|
||||
audio_driver = "null";
|
||||
microphone_enable = "false";
|
||||
menu_driver = "rgui";
|
||||
menu_show_start_screen = "false";
|
||||
video_fullscreen = "false";
|
||||
video_windowed_scale = "1";
|
||||
video_vsync = "false";
|
||||
pause_nonactive = "false";
|
||||
input_close_content = "q";
|
||||
quit_press_twice = "false";
|
||||
core_info_cache_enable = "false";
|
||||
config_save_on_exit = "true";
|
||||
};
|
||||
};
|
||||
config = pkgs.writeText "retroarch-test.cfg" ''
|
||||
libretro_directory = "/tmp/old-cores"
|
||||
'';
|
||||
override = pkgs.writeText "2048.cfg" ''
|
||||
system_directory = "/tmp/override-system"
|
||||
'';
|
||||
in
|
||||
{
|
||||
name = "retroarch-wrapper";
|
||||
meta.maintainers = pkgs.lib.teams.libretro.members;
|
||||
|
||||
nodes.machine.imports = [ ./common/x11.nix ];
|
||||
|
||||
testScript = ''
|
||||
from datetime import timedelta
|
||||
|
||||
machine.wait_for_x()
|
||||
machine.succeed("mkdir -p /tmp/old-cores /tmp/overrides/2048")
|
||||
|
||||
machine.succeed("cp ${config} /tmp/retroarch.cfg; chmod u+w /tmp/retroarch.cfg")
|
||||
machine.succeed("cp ${override} /tmp/overrides/2048/2048.cfg")
|
||||
machine.execute(
|
||||
"SDL_RENDER_DRIVER=software QT_QPA_PLATFORM=offscreen "
|
||||
"${package}/bin/retroarch -v -c /tmp/retroarch.cfg "
|
||||
"-L ${package}/lib/retroarch/cores/2048_libretro.so "
|
||||
"> /tmp/retroarch.log 2>&1 &"
|
||||
)
|
||||
machine.wait_for_window("RetroArch")
|
||||
machine.wait_until_succeeds("grep -q 'SET_SUPPORT_NO_GAME: yes' /tmp/retroarch.log")
|
||||
# Allow RetroArch's startup input-release gate to clear.
|
||||
machine.sleep(duration=timedelta(seconds=1))
|
||||
machine.send_key("q")
|
||||
machine.wait_until_succeeds(
|
||||
"grep -q 'starting dummy core' /tmp/retroarch.log", timeout=timedelta(seconds=30)
|
||||
)
|
||||
machine.succeed("grep -q 'Core-specific overrides found' /tmp/retroarch.log")
|
||||
machine.succeed("grep -q 'original configuration restored' /tmp/retroarch.log")
|
||||
machine.screenshot("closed-content")
|
||||
machine.succeed("pkill -TERM retroarch")
|
||||
machine.wait_until_fails("pgrep retroarch")
|
||||
machine.succeed(
|
||||
"grep -Fx 'libretro_directory = \"${package}/lib/retroarch/cores\"' /tmp/retroarch.cfg"
|
||||
)
|
||||
'';
|
||||
}
|
||||
@@ -44,8 +44,8 @@
|
||||
retroarch-assets,
|
||||
retroarch-bare,
|
||||
retroarch-joypad-autoconfig,
|
||||
writeText,
|
||||
symlinkJoin,
|
||||
writeText,
|
||||
# params
|
||||
enableNvidiaCgToolkit ? false,
|
||||
withGamemode ? stdenv.hostPlatform.isLinux,
|
||||
@@ -150,7 +150,10 @@ stdenv.mkDerivation (finalAttrs: {
|
||||
'';
|
||||
|
||||
passthru = {
|
||||
tests = nixosTests.retroarch;
|
||||
tests = {
|
||||
inherit (nixosTests) retroarch;
|
||||
wrapper = nixosTests.retroarch-wrapper;
|
||||
};
|
||||
updateScript = gitUpdater {
|
||||
rev-prefix = "v";
|
||||
};
|
||||
@@ -165,8 +168,8 @@ stdenv.mkDerivation (finalAttrs: {
|
||||
libretro
|
||||
makeBinaryWrapper
|
||||
retroarch-bare
|
||||
writeText
|
||||
symlinkJoin
|
||||
writeText
|
||||
cores
|
||||
;
|
||||
settings = {
|
||||
|
||||
@@ -3,31 +3,27 @@
|
||||
libretro,
|
||||
makeBinaryWrapper,
|
||||
retroarch-bare,
|
||||
writeText,
|
||||
symlinkJoin,
|
||||
writeText,
|
||||
cores ? [ ],
|
||||
settings ? { },
|
||||
}:
|
||||
|
||||
let
|
||||
settingsPath = writeText "declarative-retroarch.cfg" (
|
||||
lib.concatStringsSep "\n" (lib.mapAttrsToList (n: v: "${n} = \"${v}\"") settings)
|
||||
);
|
||||
|
||||
# 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}"
|
||||
]
|
||||
declarativeSettings =
|
||||
lib.optionalAttrs (coresPath != [ ]) {
|
||||
libretro_directory = "@retroarch@" + lib.last coresPath;
|
||||
}
|
||||
// settings;
|
||||
settingsPath = writeText "declarative-retroarch.cfg" (
|
||||
lib.generators.toKeyValue {
|
||||
mkKeyValue = lib.generators.mkKeyValueDefault {
|
||||
mkValueString = v: ''"${v}"'';
|
||||
} " = ";
|
||||
} declarativeSettings
|
||||
);
|
||||
in
|
||||
symlinkJoin {
|
||||
@@ -48,8 +44,13 @@ symlinkJoin {
|
||||
# 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}
|
||||
# Unlike -L <directory>, appended settings survive configuration reloads
|
||||
# when closing content or unloading core/game overrides.
|
||||
mkdir -p $out/share/retroarch
|
||||
substitute ${settingsPath} $out/share/retroarch/declarative-retroarch.cfg \
|
||||
--subst-var-by retroarch "$out"
|
||||
wrapProgram $out/bin/retroarch \
|
||||
--add-flags "--appendconfig=$out/share/retroarch/declarative-retroarch.cfg"
|
||||
'';
|
||||
|
||||
meta = {
|
||||
|
||||
Reference in New Issue
Block a user