diff options
author | Thiago Kenji Okada <thiagokokada@gmail.com> | 2022-10-28 23:52:09 +0100 |
---|---|---|
committer | Thiago Kenji Okada <thiagokokada@gmail.com> | 2022-10-29 12:36:58 +0100 |
commit | 784c363bd0fad7249e793c808e3883ff59d936ab (patch) | |
tree | f1275ec52774f583384a11d233af860085594ead /pkgs/applications/emulators/retroarch | |
parent | eb2992e8f84494257ef6ef6682fa1456117e3d71 (diff) |
retroarch: use libretro-core-info, simplify patch
A smaller patch should make easier to bump this package in the future.
Diffstat (limited to 'pkgs/applications/emulators/retroarch')
4 files changed, 58 insertions, 186 deletions
diff --git a/pkgs/applications/emulators/retroarch/default.nix b/pkgs/applications/emulators/retroarch/default.nix index 5c12e66c5f5dd..d0a281afc373a 100644 --- a/pkgs/applications/emulators/retroarch/default.nix +++ b/pkgs/applications/emulators/retroarch/default.nix @@ -16,6 +16,7 @@ , libGL , libGLU , libpulseaudio +, libretro-core-info , libv4l , libX11 , libXdmcp @@ -30,6 +31,7 @@ , pkg-config , python3 , SDL2 +, substituteAll , udev , vulkan-loader , wayland @@ -37,20 +39,13 @@ }: let - version = "1.12.0"; - libretroCoreInfo = fetchFromGitHub { - owner = "libretro"; - repo = "libretro-core-info"; - hash = "sha256-ByATDM0V40UJxigqVLyTWkHY5tiCC2dvZebksl8GsUI="; - rev = "v${version}"; - }; runtimeLibs = lib.optional withVulkan vulkan-loader ++ lib.optional withGamemode (lib.getLib gamemode); in stdenv.mkDerivation rec { pname = "retroarch-bare"; - inherit version; + version = "1.12.0"; src = fetchFromGitHub { owner = "libretro"; @@ -60,19 +55,12 @@ stdenv.mkDerivation rec { }; patches = [ - ./use-fixed-paths.patch + (substituteAll { + src = ./use-fixed-path-for-libretro_core_info.patch; + libretro_info_path = libretro-core-info; + }) ]; - postPatch = '' - substituteInPlace "frontend/drivers/platform_unix.c" \ - --subst-var-by libretro_directory "$out/lib" \ - --subst-var-by libretro_info_path "$out/share/libretro/info" \ - --subst-var-by out "$out" - substituteInPlace "frontend/drivers/platform_darwin.m" \ - --subst-var-by libretro_directory "$out/lib" \ - --subst-var-by libretro_info_path "$out/share/libretro/info" - ''; - nativeBuildInputs = [ pkg-config ] ++ lib.optional withWayland wayland ++ lib.optional (runtimeLibs != [ ]) makeWrapper; @@ -121,12 +109,7 @@ stdenv.mkDerivation rec { "--enable-kms" ]; - postInstall = '' - # TODO: ideally each core should have its own core information - mkdir -p $out/share/libretro/info - cp -r ${libretroCoreInfo}/* $out/share/libretro/info - '' + - lib.optionalString (runtimeLibs != [ ]) '' + postInstall = lib.optionalString (runtimeLibs != [ ]) '' wrapProgram $out/bin/retroarch \ --prefix LD_LIBRARY_PATH ':' ${lib.makeLibraryPath runtimeLibs} ''; diff --git a/pkgs/applications/emulators/retroarch/use-fixed-path-for-libretro_core_info.patch b/pkgs/applications/emulators/retroarch/use-fixed-path-for-libretro_core_info.patch new file mode 100644 index 0000000000000..256397fd49eaf --- /dev/null +++ b/pkgs/applications/emulators/retroarch/use-fixed-path-for-libretro_core_info.patch @@ -0,0 +1,41 @@ +From 6145cb9ed935621f1974655fe1ab44cf2f0fbcce Mon Sep 17 00:00:00 2001 +From: Thiago Kenji Okada <thiagokokada@gmail.com> +Date: Sat, 29 Oct 2022 12:27:55 +0100 +Subject: [PATCH] Use fixed path for libretro_core_info + +--- + configuration.c | 2 +- + frontend/drivers/platform_unix.c | 4 ++-- + 2 files changed, 3 insertions(+), 3 deletions(-) + +diff --git a/configuration.c b/configuration.c +index af3fc8f43c..c6d56308b3 100644 +--- a/configuration.c ++++ b/configuration.c +@@ -1468,7 +1468,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 fe5f7341c9..c2a91f8c99 100644 +--- a/frontend/drivers/platform_unix.c ++++ b/frontend/drivers/platform_unix.c +@@ -1799,8 +1799,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@", ++ "share/libretro/info", 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.38.0 + diff --git a/pkgs/applications/emulators/retroarch/use-fixed-paths.patch b/pkgs/applications/emulators/retroarch/use-fixed-paths.patch deleted file mode 100644 index a4837e63af7f7..0000000000000 --- a/pkgs/applications/emulators/retroarch/use-fixed-paths.patch +++ /dev/null @@ -1,154 +0,0 @@ -From 8a1cffebb23f9d2a28228cd8cbf4fd80836157e8 Mon Sep 17 00:00:00 2001 -From: Thiago Kenji Okada <thiagokokada@gmail.com> -Date: Tue, 18 Oct 2022 17:41:33 +0100 -Subject: [PATCH] Use fixed paths - ---- - configuration.c | 2 +- - frontend/drivers/platform_darwin.m | 4 +-- - frontend/drivers/platform_unix.c | 56 +++++++++++++++--------------- - 3 files changed, 31 insertions(+), 31 deletions(-) - -diff --git a/configuration.c b/configuration.c -index ac4779b2d7..d980892dda 100644 ---- a/configuration.c -+++ b/configuration.c -@@ -1468,7 +1468,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 c771ec0f55..d5e21a1f4d 100644 ---- a/frontend/drivers/platform_darwin.m -+++ b/frontend/drivers/platform_darwin.m -@@ -400,9 +400,9 @@ static void frontend_darwin_get_env(int *argc, char *argv[], - 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])); -+ "@libretro_directory@", "", 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])); -+ 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 29e9a0d633..dba8abe941 100644 ---- a/frontend/drivers/platform_unix.c -+++ b/frontend/drivers/platform_unix.c -@@ -1792,8 +1792,8 @@ static void frontend_unix_get_env(int *argc, - strlcpy(g_defaults.dirs[DEFAULT_DIR_CORE], libretro_directory, - sizeof(g_defaults.dirs[DEFAULT_DIR_CORE])); - else -- 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 -@@ -1802,27 +1802,27 @@ 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])); - -- if (path_is_directory("/usr/local/share/retroarch/assets")) -+ if (path_is_directory("@out@/local/share/retroarch/assets")) - fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_ASSETS], -- "/usr/local/share/retroarch", -+ "@out@/local/share/retroarch", - "assets", sizeof(g_defaults.dirs[DEFAULT_DIR_ASSETS])); -- else if (path_is_directory("/usr/share/retroarch/assets")) -+ else if (path_is_directory("@out@/share/retroarch/assets")) - fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_ASSETS], -- "/usr/share/retroarch", -+ "@out@/share/retroarch", - "assets", sizeof(g_defaults.dirs[DEFAULT_DIR_ASSETS])); -- else if (path_is_directory("/usr/local/share/games/retroarch/assets")) -+ else if (path_is_directory("@out@/local/share/games/retroarch/assets")) - fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_ASSETS], -- "/usr/local/share/games/retroarch", -+ "@out@/local/share/games/retroarch", - "assets", sizeof(g_defaults.dirs[DEFAULT_DIR_ASSETS])); -- else if (path_is_directory("/usr/share/games/retroarch/assets")) -+ else if (path_is_directory("@out@/share/games/retroarch/assets")) - fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_ASSETS], -- "/usr/share/games/retroarch", -+ "@out@/share/games/retroarch", - "assets", sizeof(g_defaults.dirs[DEFAULT_DIR_ASSETS])); - else - fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_ASSETS], base_path, -@@ -1834,41 +1834,41 @@ static void frontend_unix_get_env(int *argc, - fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_VIDEO_FILTER], base_path, - "filters/video", sizeof(g_defaults.dirs[DEFAULT_DIR_VIDEO_FILTER])); - #else -- if (path_is_directory("/usr/local/share/retroarch/filters/audio")) -+ if (path_is_directory("@out@/local/share/retroarch/filters/audio")) - fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_AUDIO_FILTER], -- "/usr/local/share/retroarch", -+ "@out@/local/share/retroarch", - "filters/audio", sizeof(g_defaults.dirs[DEFAULT_DIR_AUDIO_FILTER])); -- else if (path_is_directory("/usr/share/retroarch/filters/audio")) -+ else if (path_is_directory("@out@/share/retroarch/filters/audio")) - fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_AUDIO_FILTER], -- "/usr/share/retroarch", -+ "@out@/share/retroarch", - "filters/audio", sizeof(g_defaults.dirs[DEFAULT_DIR_AUDIO_FILTER])); -- else if (path_is_directory("/usr/local/share/games/retroarch/filters/audio")) -+ else if (path_is_directory("@out@/local/share/games/retroarch/filters/audio")) - fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_AUDIO_FILTER], -- "/usr/local/share/games/retroarch", -+ "@out@/local/share/games/retroarch", - "filters/audio", sizeof(g_defaults.dirs[DEFAULT_DIR_AUDIO_FILTER])); -- else if (path_is_directory("/usr/share/games/retroarch/filters/audio")) -+ else if (path_is_directory("@out@/share/games/retroarch/filters/audio")) - fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_AUDIO_FILTER], -- "/usr/share/games/retroarch", -+ "@out@/share/games/retroarch", - "filters/audio", sizeof(g_defaults.dirs[DEFAULT_DIR_AUDIO_FILTER])); - else - fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_AUDIO_FILTER], base_path, - "filters/audio", sizeof(g_defaults.dirs[DEFAULT_DIR_AUDIO_FILTER])); - -- if (path_is_directory("/usr/local/share/retroarch/filters/video")) -+ if (path_is_directory("@out@/local/share/retroarch/filters/video")) - fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_VIDEO_FILTER], -- "/usr/local/share/retroarch", -+ "@out@/local/share/retroarch", - "filters/video", sizeof(g_defaults.dirs[DEFAULT_DIR_VIDEO_FILTER])); -- else if (path_is_directory("/usr/share/retroarch/filters/video")) -+ else if (path_is_directory("@out@/share/retroarch/filters/video")) - fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_VIDEO_FILTER], -- "/usr/share/retroarch", -+ "@out@/share/retroarch", - "filters/video", sizeof(g_defaults.dirs[DEFAULT_DIR_VIDEO_FILTER])); -- else if (path_is_directory("/usr/local/share/games/retroarch/filters/video")) -+ else if (path_is_directory("@out@/local/share/games/retroarch/filters/video")) - fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_VIDEO_FILTER], -- "/usr/local/share/games/retroarch", -+ "@out@/local/share/games/retroarch", - "filters/video", sizeof(g_defaults.dirs[DEFAULT_DIR_VIDEO_FILTER])); -- else if (path_is_directory("/usr/share/games/retroarch/filters/video")) -+ else if (path_is_directory("@out@/share/games/retroarch/filters/video")) - fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_VIDEO_FILTER], -- "/usr/share/games/retroarch", -+ "@out@/share/games/retroarch", - "filters/video", sizeof(g_defaults.dirs[DEFAULT_DIR_VIDEO_FILTER])); - else - fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_VIDEO_FILTER], base_path, --- -2.37.3 - diff --git a/pkgs/applications/emulators/retroarch/wrapper.nix b/pkgs/applications/emulators/retroarch/wrapper.nix index 7ce75b22ba47b..4136d263eac4c 100644 --- a/pkgs/applications/emulators/retroarch/wrapper.nix +++ b/pkgs/applications/emulators/retroarch/wrapper.nix @@ -3,14 +3,17 @@ , makeWrapper , retroarch , symlinkJoin +, writeTextDir , cores ? [ ] }: let + # 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 (corePath: [ "--add-flags" "-L ${placeholder "out" + corePath}" ]) coresPath)); + (map (p: [ "--add-flags" "-L ${placeholder "out" + p}" ]) coresPath)); in symlinkJoin { name = "retroarch-with-cores-${lib.getVersion retroarch}"; @@ -26,11 +29,10 @@ symlinkJoin { postBuild = '' # remove core specific binaries - find $out/bin -name 'retroarch-*' -delete - # wrapProgram can't operate on symlinks - rm $out/bin/retroarch - makeWrapper ${retroarch}/bin/retroarch $out/bin/retroarch \ - ${wrapperArgs} + find $out/bin -name 'retroarch-*' -type l -delete + + # wrap binary to load cores from the proper location(s) + wrapProgram $out/bin/retroarch ${wrapperArgs} ''; meta = with retroarch.meta; { @@ -39,7 +41,7 @@ symlinkJoin { RetroArch is the reference frontend for the libretro API. '' + lib.optionalString (cores != [ ]) '' - The following cores are included: ${lib.concatStringsSep ", " (map (x: x.core) cores)} + The following cores are included: ${lib.concatStringsSep ", " (map (c: c.core) cores)} ''; mainProgram = "retroarch"; }; |