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.

+153 -8
+25
pkgs/misc/emulators/retroarch/0001-Disable-menu_show_core_updater.patch
··· 1 + From 546b343294209abbb193883ab76b679b7f99c6d3 Mon Sep 17 00:00:00 2001 2 + From: Thiago Kenji Okada <thiagokokada@gmail.com> 3 + Date: Sat, 20 Nov 2021 16:03:50 -0300 4 + Subject: [PATCH 1/2] Disable "menu_show_core_updater" 5 + 6 + --- 7 + retroarch.cfg | 2 +- 8 + 1 file changed, 1 insertion(+), 1 deletion(-) 9 + 10 + diff --git a/retroarch.cfg b/retroarch.cfg 11 + index cdcb199c9f..ab72f3920f 100644 12 + --- a/retroarch.cfg 13 + +++ b/retroarch.cfg 14 + @@ -681,7 +681,7 @@ 15 + # menu_show_online_updater = true 16 + 17 + # If disabled, will hide the ability to update cores (and core info files) inside the menu. 18 + -# menu_show_core_updater = true 19 + +menu_show_core_updater = false 20 + 21 + # If disabled, the libretro core will keep running in the background when we 22 + # are in the menu. 23 + -- 24 + 2.31.1 25 +
+80
pkgs/misc/emulators/retroarch/0002-Use-fixed-paths-on-libretro_info_path.patch
··· 1 + From 6788718299e1aba3ff8b31cd6ef012e8d3643bd3 Mon Sep 17 00:00:00 2001 2 + From: Thiago Kenji Okada <thiagokokada@gmail.com> 3 + Date: Sat, 20 Nov 2021 15:59:23 -0300 4 + Subject: [PATCH 2/2] Use fixed paths on "libretro_info_path" 5 + 6 + This patch sets "libretro_info_path" to `handle = false`, so instead of 7 + using the values from `retroarch.cfg`, it will always use the default. 8 + 9 + Also, it patches the default "libretro_info_path" to the 10 + `@libretro_info_path` string, so we can substitute it with the full path 11 + to it during build. 12 + --- 13 + configuration.c | 2 +- 14 + frontend/drivers/platform_darwin.m | 9 ++------- 15 + frontend/drivers/platform_unix.c | 8 ++++---- 16 + 3 files changed, 7 insertions(+), 12 deletions(-) 17 + 18 + diff --git a/configuration.c b/configuration.c 19 + index e6a3841324..afb1d6e2ce 100644 20 + --- a/configuration.c 21 + +++ b/configuration.c 22 + @@ -1456,7 +1456,7 @@ static struct config_path_setting *populate_settings_path( 23 + SETTING_PATH("core_options_path", 24 + settings->paths.path_core_options, false, NULL, true); 25 + SETTING_PATH("libretro_info_path", 26 + - settings->paths.path_libretro_info, false, NULL, true); 27 + + settings->paths.path_libretro_info, false, NULL, false); 28 + SETTING_PATH("content_database_path", 29 + settings->paths.path_content_database, false, NULL, true); 30 + SETTING_PATH("cheat_database_path", 31 + diff --git a/frontend/drivers/platform_darwin.m b/frontend/drivers/platform_darwin.m 32 + index f922e50c55..52732f65ae 100644 33 + --- a/frontend/drivers/platform_darwin.m 34 + +++ b/frontend/drivers/platform_darwin.m 35 + @@ -383,14 +383,9 @@ static void frontend_darwin_get_env(int *argc, char *argv[], 36 + home_dir_buf, "shaders_glsl", 37 + sizeof(g_defaults.dirs[DEFAULT_DIR_SHADER])); 38 + #endif 39 + -#ifdef HAVE_UPDATE_CORES 40 + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CORE], 41 + - home_dir_buf, "cores", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE])); 42 + -#else 43 + - fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CORE], 44 + - bundle_path_buf, "modules", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE])); 45 + -#endif 46 + - fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CORE_INFO], home_dir_buf, "info", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE_INFO])); 47 + + "@libretro_directory@", "", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE])); 48 + + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CORE_INFO], "@libretro_info_path@", "", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE_INFO])); 49 + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_OVERLAY], home_dir_buf, "overlays", sizeof(g_defaults.dirs[DEFAULT_DIR_OVERLAY])); 50 + #ifdef HAVE_VIDEO_LAYOUT 51 + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_VIDEO_LAYOUT], home_dir_buf, "layouts", sizeof(g_defaults.dirs[DEFAULT_DIR_VIDEO_LAYOUT])); 52 + diff --git a/frontend/drivers/platform_unix.c b/frontend/drivers/platform_unix.c 53 + index 722e1c595c..d87e01cf12 100644 54 + --- a/frontend/drivers/platform_unix.c 55 + +++ b/frontend/drivers/platform_unix.c 56 + @@ -1815,8 +1815,8 @@ static void frontend_unix_get_env(int *argc, 57 + strcpy_literal(base_path, "retroarch"); 58 + #endif 59 + 60 + - fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CORE], base_path, 61 + - "cores", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE])); 62 + + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CORE], "@libretro_directory@", 63 + + "", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE])); 64 + #if defined(DINGUX) 65 + /* On platforms that require manual core installation/ 66 + * removal, placing core info files in the same directory 67 + @@ -1825,8 +1825,8 @@ static void frontend_unix_get_env(int *argc, 68 + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CORE_INFO], base_path, 69 + "core_info", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE_INFO])); 70 + #else 71 + - fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CORE_INFO], base_path, 72 + - "cores", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE_INFO])); 73 + + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CORE_INFO], "@libretro_info_path@", 74 + + "", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE_INFO])); 75 + #endif 76 + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_AUTOCONFIG], base_path, 77 + "autoconfig", sizeof(g_defaults.dirs[DEFAULT_DIR_AUTOCONFIG])); 78 + -- 79 + 2.31.1 80 +
+7 -8
pkgs/misc/emulators/retroarch/default.nix
··· 55 55 }; 56 56 57 57 patches = [ 58 - # FIXME: The `retroarch.cfg` file is created once in the first run and only 59 - # updated when needed. However, the file may have out-of-date paths 60 - # In case of issues (e.g.: cores are not loading), please delete the 61 - # `$XDG_CONFIG_HOME/retroarch/retroarch.cfg` file 62 - # See: https://github.com/libretro/RetroArch/issues/13251 63 - ./fix-config.patch 58 + ./0001-Disable-menu_show_core_updater.patch 59 + ./0002-Use-fixed-paths-on-libretro_info_path.patch 64 60 ]; 65 61 66 62 postPatch = '' 67 - substituteInPlace retroarch.cfg \ 63 + substituteInPlace "frontend/drivers/platform_unix.c" \ 64 + --replace "@libretro_directory@" "$out/lib" \ 65 + --replace "@libretro_info_path@" "$out/share/libretro/info" 66 + substituteInPlace "frontend/drivers/platform_darwin.m" \ 68 67 --replace "@libretro_directory@" "$out/lib" \ 69 - --replace "@libretro_info_path@" "$out/share/libretro/info" \ 68 + --replace "@libretro_info_path@" "$out/share/libretro/info" 70 69 ''; 71 70 72 71 nativeBuildInputs = [ pkg-config wayland ] ++
+13
pkgs/misc/emulators/retroarch/disable-menu-show-core-updater.patch
··· 1 + diff --git a/retroarch.cfg b/retroarch.cfg 2 + index cdcb199c9f..ab72f3920f 100644 3 + --- a/retroarch.cfg 4 + +++ b/retroarch.cfg 5 + @@ -681,7 +681,7 @@ 6 + # menu_show_online_updater = true 7 + 8 + # If disabled, will hide the ability to update cores (and core info files) inside the menu. 9 + -# menu_show_core_updater = true 10 + +menu_show_core_updater = false 11 + 12 + # If disabled, the libretro core will keep running in the background when we 13 + # are in the menu.
+28
pkgs/misc/emulators/retroarch/fix-libretro-paths.patch
··· 1 + diff --git a/configuration.c b/configuration.c 2 + index e6a3841324..afb1d6e2ce 100644 3 + --- a/configuration.c 4 + +++ b/configuration.c 5 + @@ -1456,7 +1456,7 @@ static struct config_path_setting *populate_settings_path( 6 + SETTING_PATH("core_options_path", 7 + settings->paths.path_core_options, false, NULL, true); 8 + SETTING_PATH("libretro_info_path", 9 + - settings->paths.path_libretro_info, false, NULL, true); 10 + + settings->paths.path_libretro_info, false, NULL, false); 11 + SETTING_PATH("content_database_path", 12 + settings->paths.path_content_database, false, NULL, true); 13 + SETTING_PATH("cheat_database_path", 14 + diff --git a/frontend/drivers/platform_unix.c b/frontend/drivers/platform_unix.c 15 + index 722e1c595c..e7313ee038 100644 16 + --- a/frontend/drivers/platform_unix.c 17 + +++ b/frontend/drivers/platform_unix.c 18 + @@ -1825,8 +1825,8 @@ static void frontend_unix_get_env(int *argc, 19 + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CORE_INFO], base_path, 20 + "core_info", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE_INFO])); 21 + #else 22 + - fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CORE_INFO], base_path, 23 + - "cores", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE_INFO])); 24 + + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CORE_INFO], "@libretro_info_path@", 25 + + "", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE_INFO])); 26 + #endif 27 + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_AUTOCONFIG], base_path, 28 + "autoconfig", sizeof(g_defaults.dirs[DEFAULT_DIR_AUTOCONFIG]));