From 03e35cfb6579745cecd0d629403438b90022e324 Mon Sep 17 00:00:00 2001 From: Thiago Kenji Okada Date: Sat, 20 Nov 2021 16:08:36 -0300 Subject: [PATCH] retroarch: use fixed paths on "libretro_info_path" This commit introduces a patch that hardcodes "libretro_info_path" directly in the RetroArch code, without the issues of the previous approach. With this commit, RetroArch stops reading "libretro_info_path" from `retroarch.cfg` file, and always use the default. --- .../0001-Disable-menu_show_core_updater.patch | 25 ++++++ ...se-fixed-paths-on-libretro_info_path.patch | 80 +++++++++++++++++++ pkgs/misc/emulators/retroarch/default.nix | 15 ++-- .../disable-menu-show-core-updater.patch | 13 +++ .../retroarch/fix-libretro-paths.patch | 28 +++++++ 5 files changed, 153 insertions(+), 8 deletions(-) create mode 100644 pkgs/misc/emulators/retroarch/0001-Disable-menu_show_core_updater.patch create mode 100644 pkgs/misc/emulators/retroarch/0002-Use-fixed-paths-on-libretro_info_path.patch create mode 100644 pkgs/misc/emulators/retroarch/disable-menu-show-core-updater.patch create mode 100644 pkgs/misc/emulators/retroarch/fix-libretro-paths.patch diff --git a/pkgs/misc/emulators/retroarch/0001-Disable-menu_show_core_updater.patch b/pkgs/misc/emulators/retroarch/0001-Disable-menu_show_core_updater.patch new file mode 100644 index 000000000000..75018dc8c4d1 --- /dev/null +++ b/pkgs/misc/emulators/retroarch/0001-Disable-menu_show_core_updater.patch @@ -0,0 +1,25 @@ +From 546b343294209abbb193883ab76b679b7f99c6d3 Mon Sep 17 00:00:00 2001 +From: Thiago Kenji Okada +Date: Sat, 20 Nov 2021 16:03:50 -0300 +Subject: [PATCH 1/2] Disable "menu_show_core_updater" + +--- + retroarch.cfg | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/retroarch.cfg b/retroarch.cfg +index cdcb199c9f..ab72f3920f 100644 +--- a/retroarch.cfg ++++ b/retroarch.cfg +@@ -681,7 +681,7 @@ + # menu_show_online_updater = true + + # If disabled, will hide the ability to update cores (and core info files) inside the menu. +-# menu_show_core_updater = true ++menu_show_core_updater = false + + # If disabled, the libretro core will keep running in the background when we + # are in the menu. +-- +2.31.1 + diff --git a/pkgs/misc/emulators/retroarch/0002-Use-fixed-paths-on-libretro_info_path.patch b/pkgs/misc/emulators/retroarch/0002-Use-fixed-paths-on-libretro_info_path.patch new file mode 100644 index 000000000000..9aa8db6ab048 --- /dev/null +++ b/pkgs/misc/emulators/retroarch/0002-Use-fixed-paths-on-libretro_info_path.patch @@ -0,0 +1,80 @@ +From 6788718299e1aba3ff8b31cd6ef012e8d3643bd3 Mon Sep 17 00:00:00 2001 +From: Thiago Kenji Okada +Date: Sat, 20 Nov 2021 15:59:23 -0300 +Subject: [PATCH 2/2] Use fixed paths on "libretro_info_path" + +This patch sets "libretro_info_path" to `handle = false`, so instead of +using the values from `retroarch.cfg`, it will always use the default. + +Also, it patches the default "libretro_info_path" to the +`@libretro_info_path` string, so we can substitute it with the full path +to it during build. +--- + configuration.c | 2 +- + frontend/drivers/platform_darwin.m | 9 ++------- + frontend/drivers/platform_unix.c | 8 ++++---- + 3 files changed, 7 insertions(+), 12 deletions(-) + +diff --git a/configuration.c b/configuration.c +index e6a3841324..afb1d6e2ce 100644 +--- a/configuration.c ++++ b/configuration.c +@@ -1456,7 +1456,7 @@ static struct config_path_setting *populate_settings_path( + SETTING_PATH("core_options_path", + settings->paths.path_core_options, false, NULL, true); + SETTING_PATH("libretro_info_path", +- settings->paths.path_libretro_info, false, NULL, true); ++ settings->paths.path_libretro_info, false, NULL, false); + SETTING_PATH("content_database_path", + settings->paths.path_content_database, false, NULL, true); + SETTING_PATH("cheat_database_path", +diff --git a/frontend/drivers/platform_darwin.m b/frontend/drivers/platform_darwin.m +index f922e50c55..52732f65ae 100644 +--- a/frontend/drivers/platform_darwin.m ++++ b/frontend/drivers/platform_darwin.m +@@ -383,14 +383,9 @@ static void frontend_darwin_get_env(int *argc, char *argv[], + home_dir_buf, "shaders_glsl", + sizeof(g_defaults.dirs[DEFAULT_DIR_SHADER])); + #endif +-#ifdef HAVE_UPDATE_CORES + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CORE], +- home_dir_buf, "cores", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE])); +-#else +- fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CORE], +- bundle_path_buf, "modules", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE])); +-#endif +- fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CORE_INFO], home_dir_buf, "info", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE_INFO])); ++ "@libretro_directory@", "", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE])); ++ fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CORE_INFO], "@libretro_info_path@", "", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE_INFO])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_OVERLAY], home_dir_buf, "overlays", sizeof(g_defaults.dirs[DEFAULT_DIR_OVERLAY])); + #ifdef HAVE_VIDEO_LAYOUT + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_VIDEO_LAYOUT], home_dir_buf, "layouts", sizeof(g_defaults.dirs[DEFAULT_DIR_VIDEO_LAYOUT])); +diff --git a/frontend/drivers/platform_unix.c b/frontend/drivers/platform_unix.c +index 722e1c595c..d87e01cf12 100644 +--- a/frontend/drivers/platform_unix.c ++++ b/frontend/drivers/platform_unix.c +@@ -1815,8 +1815,8 @@ static void frontend_unix_get_env(int *argc, + strcpy_literal(base_path, "retroarch"); + #endif + +- fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CORE], base_path, +- "cores", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE])); ++ fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CORE], "@libretro_directory@", ++ "", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE])); + #if defined(DINGUX) + /* On platforms that require manual core installation/ + * removal, placing core info files in the same directory +@@ -1825,8 +1825,8 @@ static void frontend_unix_get_env(int *argc, + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CORE_INFO], base_path, + "core_info", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE_INFO])); + #else +- fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CORE_INFO], base_path, +- "cores", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE_INFO])); ++ fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CORE_INFO], "@libretro_info_path@", ++ "", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE_INFO])); + #endif + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_AUTOCONFIG], base_path, + "autoconfig", sizeof(g_defaults.dirs[DEFAULT_DIR_AUTOCONFIG])); +-- +2.31.1 + diff --git a/pkgs/misc/emulators/retroarch/default.nix b/pkgs/misc/emulators/retroarch/default.nix index 21cbcb801616..122dfcd0f274 100644 --- a/pkgs/misc/emulators/retroarch/default.nix +++ b/pkgs/misc/emulators/retroarch/default.nix @@ -55,18 +55,17 @@ stdenv.mkDerivation rec { }; patches = [ - # FIXME: The `retroarch.cfg` file is created once in the first run and only - # updated when needed. However, the file may have out-of-date paths - # In case of issues (e.g.: cores are not loading), please delete the - # `$XDG_CONFIG_HOME/retroarch/retroarch.cfg` file - # See: https://github.com/libretro/RetroArch/issues/13251 - ./fix-config.patch + ./0001-Disable-menu_show_core_updater.patch + ./0002-Use-fixed-paths-on-libretro_info_path.patch ]; postPatch = '' - substituteInPlace retroarch.cfg \ + substituteInPlace "frontend/drivers/platform_unix.c" \ --replace "@libretro_directory@" "$out/lib" \ - --replace "@libretro_info_path@" "$out/share/libretro/info" \ + --replace "@libretro_info_path@" "$out/share/libretro/info" + substituteInPlace "frontend/drivers/platform_darwin.m" \ + --replace "@libretro_directory@" "$out/lib" \ + --replace "@libretro_info_path@" "$out/share/libretro/info" ''; nativeBuildInputs = [ pkg-config wayland ] ++ diff --git a/pkgs/misc/emulators/retroarch/disable-menu-show-core-updater.patch b/pkgs/misc/emulators/retroarch/disable-menu-show-core-updater.patch new file mode 100644 index 000000000000..34fea554ef71 --- /dev/null +++ b/pkgs/misc/emulators/retroarch/disable-menu-show-core-updater.patch @@ -0,0 +1,13 @@ +diff --git a/retroarch.cfg b/retroarch.cfg +index cdcb199c9f..ab72f3920f 100644 +--- a/retroarch.cfg ++++ b/retroarch.cfg +@@ -681,7 +681,7 @@ + # menu_show_online_updater = true + + # If disabled, will hide the ability to update cores (and core info files) inside the menu. +-# menu_show_core_updater = true ++menu_show_core_updater = false + + # If disabled, the libretro core will keep running in the background when we + # are in the menu. diff --git a/pkgs/misc/emulators/retroarch/fix-libretro-paths.patch b/pkgs/misc/emulators/retroarch/fix-libretro-paths.patch new file mode 100644 index 000000000000..203ce836533d --- /dev/null +++ b/pkgs/misc/emulators/retroarch/fix-libretro-paths.patch @@ -0,0 +1,28 @@ +diff --git a/configuration.c b/configuration.c +index e6a3841324..afb1d6e2ce 100644 +--- a/configuration.c ++++ b/configuration.c +@@ -1456,7 +1456,7 @@ static struct config_path_setting *populate_settings_path( + SETTING_PATH("core_options_path", + settings->paths.path_core_options, false, NULL, true); + SETTING_PATH("libretro_info_path", +- settings->paths.path_libretro_info, false, NULL, true); ++ settings->paths.path_libretro_info, false, NULL, false); + SETTING_PATH("content_database_path", + settings->paths.path_content_database, false, NULL, true); + SETTING_PATH("cheat_database_path", +diff --git a/frontend/drivers/platform_unix.c b/frontend/drivers/platform_unix.c +index 722e1c595c..e7313ee038 100644 +--- a/frontend/drivers/platform_unix.c ++++ b/frontend/drivers/platform_unix.c +@@ -1825,8 +1825,8 @@ static void frontend_unix_get_env(int *argc, + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CORE_INFO], base_path, + "core_info", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE_INFO])); + #else +- fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CORE_INFO], base_path, +- "cores", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE_INFO])); ++ fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CORE_INFO], "@libretro_info_path@", ++ "", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE_INFO])); + #endif + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_AUTOCONFIG], base_path, + "autoconfig", sizeof(g_defaults.dirs[DEFAULT_DIR_AUTOCONFIG]));