about summary refs log tree commit diff
path: root/pkgs/applications/emulators
diff options
context:
space:
mode:
authorThiago Kenji Okada <thiagokokada@gmail.com>2022-12-18 22:12:48 +0000
committerThiago Kenji Okada <thiagokokada@gmail.com>2022-12-22 12:42:08 +0000
commit8df7516450144813e0b67acc027c0e2425366446 (patch)
tree7f3f53666de10f2b8a0a35d2ce4cd254773aade6 /pkgs/applications/emulators
parentcb93ebaeec23e0f4814667a6e1c956bb0db08783 (diff)
retroarchBare: add with{Assets,CoreInfo} options
Diffstat (limited to 'pkgs/applications/emulators')
-rw-r--r--pkgs/applications/emulators/retroarch/default.nix19
-rw-r--r--pkgs/applications/emulators/retroarch/move-retroarch-assets-to-retroarch_assets_path.patch60
2 files changed, 76 insertions, 3 deletions
diff --git a/pkgs/applications/emulators/retroarch/default.nix b/pkgs/applications/emulators/retroarch/default.nix
index 5512fa276e825..d43c124fca49b 100644
--- a/pkgs/applications/emulators/retroarch/default.nix
+++ b/pkgs/applications/emulators/retroarch/default.nix
@@ -2,6 +2,8 @@
 , stdenv
 , nixosTests
 , enableNvidiaCgToolkit ? false
+, withAssets ? false
+, withCoreInfo ? false
 , withGamemode ? stdenv.isLinux
 , withVulkan ? stdenv.isLinux
 , withWayland ? stdenv.isLinux
@@ -30,6 +32,7 @@
 , nvidia_cg_toolkit
 , pkg-config
 , python3
+, retroarch-assets
 , SDL2
 , substituteAll
 , udev
@@ -54,12 +57,16 @@ stdenv.mkDerivation rec {
     rev = "v${version}";
   };
 
-  patches = [
+  patches = lib.optional withAssets
+    (substituteAll {
+      src = ./move-retroarch-assets-to-retroarch_assets_path.patch;
+      retroarch_assets_path = retroarch-assets;
+    })
+  ++ lib.optional withCoreInfo
     (substituteAll {
       src = ./use-fixed-path-for-libretro_core_info.patch;
       libretro_info_path = libretro-core-info;
-    })
-  ];
+    });
 
   nativeBuildInputs = [ pkg-config ] ++
     lib.optional withWayland wayland ++
@@ -103,6 +110,12 @@ stdenv.mkDerivation rec {
     "--disable-builtinzlib"
     "--disable-builtinflac"
   ] ++
+  lib.optionals withAssets [
+    "--disable-update_assets"
+    # TODO: investigate why we also need this patch:
+    # ./move-retroarch-assets-to-retroarch_assets_path.patch
+    "--with-assets_dir=${retroarch-assets}"
+  ] ++
   lib.optionals stdenv.isLinux [
     "--enable-dbus"
     "--enable-egl"
diff --git a/pkgs/applications/emulators/retroarch/move-retroarch-assets-to-retroarch_assets_path.patch b/pkgs/applications/emulators/retroarch/move-retroarch-assets-to-retroarch_assets_path.patch
new file mode 100644
index 0000000000000..477cc4c626fbf
--- /dev/null
+++ b/pkgs/applications/emulators/retroarch/move-retroarch-assets-to-retroarch_assets_path.patch
@@ -0,0 +1,60 @@
+From b3ccf05014f4a79800d8bed05b0dcfdc010e191c Mon Sep 17 00:00:00 2001
+From: Thiago Kenji Okada <thiagokokada@gmail.com>
+Date: Sun, 18 Dec 2022 22:06:48 +0000
+Subject: [PATCH 2/2] Move retroarch assets path to @retroarch_assets_path@
+
+---
+ configuration.c                  |  2 +-
+ frontend/drivers/platform_unix.c | 16 ++++++++--------
+ 2 files changed, 9 insertions(+), 9 deletions(-)
+
+diff --git a/configuration.c b/configuration.c
+index 06a99236c2..15b575d8a2 100644
+--- a/configuration.c
++++ b/configuration.c
+@@ -1539,7 +1539,7 @@ static struct config_path_setting *populate_settings_path(
+    SETTING_PATH("core_assets_directory",
+          settings->paths.directory_core_assets, true, NULL, true);
+    SETTING_PATH("assets_directory",
+-         settings->paths.directory_assets, true, NULL, true);
++         settings->paths.directory_assets, true, NULL, false);
+    SETTING_PATH("dynamic_wallpapers_directory",
+          settings->paths.directory_dynamic_wallpapers, true, NULL, true);
+    SETTING_PATH("thumbnails_directory",
+diff --git a/frontend/drivers/platform_unix.c b/frontend/drivers/platform_unix.c
+index 43ea5f80c9..01b6cccbcc 100644
+--- a/frontend/drivers/platform_unix.c
++++ b/frontend/drivers/platform_unix.c
+@@ -1778,21 +1778,21 @@ static void frontend_unix_get_env(int *argc,
+    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("@retroarch_assets_path@/local/share/retroarch/assets"))
+       fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_ASSETS],
+-            "/usr/local/share/retroarch",
++            "@retroarch_assets_path@/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("@retroarch_assets_path@/share/retroarch/assets"))
+       fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_ASSETS],
+-            "/usr/share/retroarch",
++            "@retroarch_assets_path@/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("@retroarch_assets_path@/local/share/games/retroarch/assets"))
+       fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_ASSETS],
+-            "/usr/local/share/games/retroarch",
++            "@retroarch_assets_path@/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("@retroarch_assets_path@/share/games/retroarch/assets"))
+       fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_ASSETS],
+-            "/usr/share/games/retroarch",
++            "@retroarch_assets_path@/share/games/retroarch",
+             "assets", sizeof(g_defaults.dirs[DEFAULT_DIR_ASSETS]));
+    else
+       fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_ASSETS], base_path,
+-- 
+2.38.1
+