~ruther/guix-local

186a9714a3ab6d6d4342d8a85873ad071f7b3617 — Maxim Cournoyer 1 year, 2 months ago 9d1f9a8
gnu: dolphin-emu: Update to 2506-0.79a3af2.

* gnu/packages/emulators.scm (dolphin-emu): Update to 2506-0.79a3af2.
[source] {patches}: Update patches.
(dolphin-rcheevos-submodule): New variable.
[source]: Refine and update snippet.
[#:phases] {remove-unittests-target-post-build-command}: Delete.
{generate-fonts&hardcode-libvulkan-path}: Fix typo in phase name. Remove
obsolete cstdint patching.
{post-check}: Delete.
[#:configure-flags]: Streamline. Add -DUSE_DISCORD_PRESENCE=OFF.
[native-inputs]: Add googletest
[inputs]: Replace ffmpeg-4 with ffmpeg. Replace fmt-7 with fmt-11. Replace
gtk+-2 with gtk+ and minizip-ng-compat with minizip-ng. Add lz4,
mgba-for-dolphin, qtsvg, spirv-cross, spng, tinygltf, vulkan-headers,
vulkan-memory-allocator and watcher. Replace qtbase-5 with qtbase. Replace
sdl2 with sdl3. Replace sfml-2 with sfml. Remove soundtouch-1/integer-samples.
(libretro-dolphin-emu): Update to 5.0-1.a09f78f.
[source]: Break inheritance with dolphin-emu, adjusting snippet for its older
code base.
[patches]: Apply libretro-dolphin-emu-libusb-assert.patch and
libretro-dolphin-emu-vulkan-headers.patch.
[#:phases] {link-unittest-to-gtest}: New phase.
[inputs]: Do not inherit from dolphin-emu. Replace fmt-7 with fmt. Replace
minizip-ng with minizip-ng-compat.
googletest, vulkan-headers.
* gnu/packages/patches/dolphin-emu-data.patch: Delete file.
* gnu/packages/patches/dolphin-emu-unbundle-tinygltf.patch
* gnu/packages/patches/dolphin-emu-unbundle-watcher.patch
* gnu/packages/patches/libretro-dolphin-emu-gc-font-tool.patch
* gnu/packages/patches/libretro-dolphin-emu-libusb-assert.patch
* gnu/packages/patches/libretro-dolphin-emu-vulkan-headers.patch: New files.
* gnu/local.mk (dist_patch_DATA): Update accordingly.

Fixes: #1327
Change-Id: I5a870a5e29c1ca243fb1d5e049ee06c5e254a04f
M gnu/local.mk => gnu/local.mk +5 -1
@@ 1214,7 1214,8 @@ dist_patch_DATA =						\
  %D%/packages/patches/docbook2x-static-datadir-evaluation.patch	\
  %D%/packages/patches/doc++-include-directives.patch		\
  %D%/packages/patches/doc++-segfault-fix.patch			\
  %D%/packages/patches/dolphin-emu-data.patch			\
  %D%/packages/patches/dolphin-emu-unbundle-tinygltf.patch      \
  %D%/packages/patches/dolphin-emu-unbundle-watcher.patch       \
  %D%/packages/patches/dovecot-opensslv3.patch			\
  %D%/packages/patches/dovecot-trees-support-dovecot-2.3.patch	\
  %D%/packages/patches/dstat-fix-crash-when-specifying-delay.patch	\


@@ 1687,6 1688,9 @@ dist_patch_DATA =						\
  %D%/packages/patches/libguestfs-syms.patch            	\
  %D%/packages/patches/libinfinity-renew-test-certificate.patch \
  %D%/packages/patches/libretro-dolphin-emu-data.patch		\
  %D%/packages/patches/libretro-dolphin-emu-gc-font-tool.patch  \
  %D%/packages/patches/libretro-dolphin-emu-libusb-assert.patch \
  %D%/packages/patches/libretro-dolphin-emu-vulkan-headers.patch        \
  %D%/packages/patches/librewolf-add-store-to-rdd-allowlist.patch       \
  %D%/packages/patches/librewolf-neuter-locale-download.patch	\
  %D%/packages/patches/librewolf-use-system-wide-dir.patch	\

M gnu/packages/emulators.scm => gnu/packages/emulators.scm +211 -129
@@ 15,7 15,7 @@
;;; Copyright © 2020 Christopher Howard <christopher@librehacker.com>
;;; Copyright © 2021 Felipe Balbi <balbi@kernel.org>
;;; Copyright © 2021, 2024 Felix Gruber <felgru@posteo.net>
;;; Copyright © 2021, 2024, 2025 Maxim Cournoyer <maxim@guixotic.coop>
;;; Copyright © 2021, 2024-2025 Maxim Cournoyer <maxim@guixotic.coop>
;;; Copyright © 2021 Guillaume Le Vaillant <glv@posteo.net>
;;; Copyright © 2023 c4droid <c4droid@foxmail.com>
;;; Copyright © 2023 Yovan Naumovski <yovan@gorski.stream>


@@ 73,6 73,7 @@
  #:use-module (gnu packages digest)
  #:use-module (gnu packages engineering)
  #:use-module (gnu packages elf)
  #:use-module (gnu packages file-systems)
  #:use-module (gnu packages flex)
  #:use-module (gnu packages fltk)
  #:use-module (gnu packages fonts)


@@ 111,6 112,7 @@
  #:use-module (gnu packages texinfo)
  #:use-module (gnu packages textutils)
  #:use-module (gnu packages tls)
  #:use-module (gnu packages toolkits)
  #:use-module (gnu packages upnp)
  #:use-module (gnu packages video)
  #:use-module (gnu packages vulkan)


@@ 322,97 324,96 @@ console.")
It aims to support Nintendo DSi and 3DS as well.")
   (license license:gpl3+)))

;; Building from recent Git because the official 5.0 release no longer builds.
;; Following commits and revision numbers of beta versions listed at
;; https://dolphin-emu.org/download/.
(define dolphin-rcheevos-submodule
  (origin
    (method git-fetch)
    (uri (git-reference
           (url "https://github.com/RetroAchievements/rcheevos")
           (commit "b443902b1cdfee5a66b09fec20a94d2d2afaf2ec")))
    (file-name "dolphin-rcheevos-submodule-checkout")
    (sha256
     (base32
      "1118l6ln73rjj7hw45712lm2i24m96nygiiw57hlcyaxijppl1vj"))))

(define-public dolphin-emu
  (let ((commit "f9deb68aee962564b1495ff04c54c015e58d086f")
        (revision "13669"))
  ;; Note: make sure to update the above rcheevos commit to match that of the
  ;; corresponding git submodule in dolphin (see:
  ;; <https://github.com/dolphin-emu/dolphin/tree/master/Externals/>).
  (let ((commit "64d4c4020cf444d5afea708b38d1b363e532c7ba")
        (revision "0"))
    (package
      (name "dolphin-emu")
      (version (git-version "5.0" revision commit))
      (version (git-version "2506" revision commit))
      (source
       (origin
         (method git-fetch)
         (uri (git-reference
               (url "https://github.com/dolphin-emu/dolphin")
               (commit commit)))
                (url "https://github.com/dolphin-emu/dolphin")
                (commit commit)))
         (file-name (git-file-name name version))
         (sha256
          (base32 "1p8qsxlabgmz3nic0a9ghh9d3lzl5f8i3kmdrrvx6w8kdlp33018"))
          (base32 "095326n1dznaplll5crlfdg2d39qxxlhgch5fn7vz8majz0qb5pg"))
         (modules '((guix build utils)
                    (ice-9 regex)))
                    (ice-9 ftw)
                    (ice-9 regex)
                    (srfi srfi-26)))
         (snippet
          '(begin
             ;; Remove external stuff we don't need.
             (for-each (lambda (dir)
                         (delete-file-recursively
                          (string-append "Externals/" dir)))
                       '("LZO" "OpenAL" "Qt" "SFML" "bzip2"
                         ;; XXX: Attempting to use the vulkan-headers package
                         ;; results in "error:
                         ;; ‘VK_PRESENT_MODE_RANGE_SIZE_KHR’ was not declared
                         ;; in this scope".
                         ;;"Vulkan"
                         "cubeb" "curl" "enet"
                         "ffmpeg" "fmt" "gettext"
                         ;; XXX: Attempting to use an unbundled glslang at the
                         ;; exact commit used by Dolphin still results in
                         ;; "error: ‘DefaultTBuiltInResource’ is not a member
                         ;; of ‘glslang’".
                         ;;"glslang"
                         ;; XXX: Googletest cannot currently easily be
                         ;; unbundled, as there are missing linking
                         ;; directives.
                         ;;"gtest"
                         "hidapi" "libpng" "libusb" "mbedtls"
                         "miniupnpc" "minizip" "MoltenVK" "pugixml"
                         "soundtouch"
                         "xxhash" "zlib" "zstd"))
             ;; Clean up the source.
             (for-each delete-file
                       (find-files
                        "."
                        (lambda (file _)
                          (and (string-match "\\.(bin|dsy|exe|jar|rar)$" file)
                               ;; Preserve the important wc24 .bin
                               ;; configuration *data* files.
                               (not (member (basename file)
                                            '("misc.bin"
                                              "nwc24dl.bin"
                                              "nwc24fl.bin"
                                              "nwc24fls.bin")))))))
             ;; Do not attempt to include now-missing directories.
             (substitute* "CMakeLists.txt"
               ((".*add_subdirectory.*Externals/enet.*") "")
               ((".*add_subdirectory.*Externals/soundtouch.*") "")
               ((".*add_subdirectory.*Externals/xxhash.*") ""))))
         (patches (search-patches "dolphin-emu-data.patch"))))
          #~(begin
              (define (delete-all-but directory . preserve)
                (with-directory-excursion directory
                  (let* ((pred (negate (cut member <>
                                            (cons* "." ".." preserve))))
                         (items (scandir "." pred)))
                    (for-each (cut delete-file-recursively <>) items))))

              ;; Clean up the source from bundled libraries we don't need.
              (delete-all-but "Externals"
                              ;; XXX: The build system is currently hard-coded
                              ;; to rely on these bundled copies.
                              "Bochs_disasm"
                              "FatFs"
                              "FreeSurround"
                              "cpp-optparse"
                              "expr"
                              "glslang"
                              "imgui"
                              "implot"  ;submodule
                              "picojson"
                              "rangeset"
                              "rcheevos") ;submodule
              (with-directory-excursion "Externals"
                (copy-recursively #$dolphin-rcheevos-submodule
                                  "rcheevos/rcheevos")
                (copy-recursively #$(package-source implot)
                                  "implot/implot"))

              (for-each delete-file
                        (find-files
                         "."
                         (lambda (file _)
                           (and (string-match "\\.(bin|dsy|exe|jar|rar)$" file)
                                ;; Preserve the important wc24 .bin
                                ;; configuration *data* files.
                                (not (member (basename file)
                                             '("misc.bin"
                                               "nwc24dl.bin"
                                               "nwc24fl.bin"
                                               "nwc24fls.bin")))))))))
         (patches (search-patches "dolphin-emu-unbundle-watcher.patch"
                                  "dolphin-emu-unbundle-tinygltf.patch"))))
      (build-system cmake-build-system)
      (arguments
       (list
        #:phases
        #~(modify-phases %standard-phases
            (add-before 'configure 'remove-unittests-target-post-build-command
              (lambda _
                ;; To skip a few problematic tests, CTest will be manually
                ;; invoked in the post-check phase.
                (with-directory-excursion "Source/UnitTests"
                  (substitute* "CMakeLists.txt"
                    (("add_custom_command\\(TARGET unittests POST_BUILD.*")
                     "")))))
            (add-before 'configure 'generate-fonts&hardcore-libvulkan-path
            (add-before 'configure 'generate-fonts&hardcode-libvulkan-path
              (lambda* (#:key inputs #:allow-other-keys)
                (let ((fontfile
                       (search-input-file inputs
                                          "/share/fonts/truetype/wqy-microhei.ttc"))
                       (search-input-file
                        inputs "/share/fonts/truetype/wqy-microhei.ttc"))
                      (libvulkan
                       (search-input-file inputs "/lib/libvulkan.so")))
                  (chdir "docs")
                  ;; Include a missing header, needed for gcc@14.
                  (substitute* "gc-font-tool.cpp"
                    (("#include <cstring>" all)
                      (string-append all "\n#include <cstdint>")))
                  (invoke "bash" "-c" "g++ -O2 $(freetype-config \
--cflags --libs) gc-font-tool.cpp -o gc-font-tool")
                  (invoke "./gc-font-tool" "a" fontfile "font_western.bin")


@@ 424,21 425,6 @@ It aims to support Nintendo DSi and 3DS as well.")
                    (("\"vulkan\", 1") (string-append "\"vulkan\""))
                    (("\"vulkan\"") (string-append "\"" libvulkan "\""))
                    (("Common::DynamicLibrary::GetVersionedFilename") "")))))
            (add-after 'check 'post-check
              (lambda* (#:key tests? #:allow-other-keys)
                (when tests?
                  (with-directory-excursion "Source/UnitTests"
                    (invoke "ctest" "-V" "--output-on-failure"
                            ;; These tests fail due to libusb failing to
                            ;; init inside the build container.
                            "-E" (string-join
                                  '("MMIOTest"
                                    "PageFaultTest"
                                    "CoreTimingTest"
                                    "FileSystemTest"
                                    "PowerPCTest"
                                    "VertexLoaderTest")
                                  "|"))))))
            (add-before 'install 'build-codeloader.bin
              (lambda _
                (with-directory-excursion "../source/docs"


@@ 462,26 448,14 @@ It aims to support Nintendo DSi and 3DS as well.")
                (with-directory-excursion "../source"
                  (invoke "python3" "docs/DSP/free_dsp_rom/generate_coefs.py")
                  (rename-file "dsp_coef.bin" "Data/Sys/GC/dsp_coef.bin")))))
        ;; The FindGTK2 cmake script only checks hardcoded directories for
        ;; glib/gtk headers.  Also add some include directories via the CXX
        ;; flags to let GCC find some headers not actively searched by the
        ;; build system.
        #:configure-flags
        #~(list (string-append "-DCMAKE_CXX_FLAGS="
                               "-I" (search-input-directory
                                     %build-inputs "include/soundtouch"))
                "-DDSPTOOL=ON"
                (string-append "-DX11_INCLUDE_DIR="
                               #$(this-package-input "libx11")
                               "/include")
                (string-append "-DX11_LIBRARIES="
                               (search-input-file %build-inputs
                                                  "lib/libX11.so"))
                "-DX11_FOUND=1")
        #~(list "-DUSE_DISCORD_PRESENCE=OFF" ;avoid bundled discord-rpc lib
                "-DDSPTOOL=ON")
        #:test-target "unittests"))
      (native-inputs
       (list (cross-gcc "powerpc-linux-gnu")
             gettext-minimal
             googletest
             pkg-config
             python-minimal
             python-numpy))


@@ 494,14 468,14 @@ It aims to support Nintendo DSi and 3DS as well.")
             curl
             enet
             eudev
             ffmpeg-4
             fmt-7
             ffmpeg
             fmt-11
             font-wqy-microhei
             freetype
             glew
             glib
             glu
             gtk+-2
             gtk+
             hidapi
             libevdev
             libpng


@@ 509,20 483,28 @@ It aims to support Nintendo DSi and 3DS as well.")
             libx11
             libxi
             libxrandr
             lz4
             lzo
             mbedtls-lts
             mgba-for-dolphin
             mesa
             miniupnpc
             minizip-ng-compat
             minizip-ng
             openal
             pugixml
             pulseaudio
             qtbase-5
             sdl2
             sfml-2
             qtbase
             qtsvg
             sdl3
             sfml
             soil
             soundtouch-1/integer-samples
             spirv-cross
             spng
             tinygltf
             vulkan-headers             ;references loader
             vulkan-loader
             vulkan-memory-allocator
             watcher
             xxhash
             zlib
             `(,zstd "lib")))


@@ 536,36 518,102 @@ turbo speed, networked multiplayer, and graphical enhancements.")
      ;; dolphin/Data/Sys/GC/font_*.bin: Licensed under ASL2.0.
      (license (list license:gpl2+ license:asl2.0 license:fdl1.2+)))))

;;; XXX: The libretro port is currently based on an old version of dolphin, so
;;; its packaging/inputs are lagging behind.
(define-public libretro-dolphin-emu
  ;; There are no tag or release; use the latest commit.
  (let ((commit "89a4df725d4eb24537728f7d655cddb1add25c18")
        (revision "0"))
  (let ((commit "a09f78f735f0d2184f64ba5b134abe98ee99c65f")
        (revision "1"))
    (package
      (inherit dolphin-emu)
      (name "libretro-dolphin-emu")
      (version (git-version "5.0" revision commit))
      (source (origin
                (inherit (package-source dolphin-emu))
                (method git-fetch)
                (uri (git-reference
                      (url "https://github.com/libretro/dolphin")
                      (commit commit)))
                (file-name (git-file-name name version))
                (sha256
                 (base32
                  "1fvm6hy0ihc0j3sgv88a7ak08c0kyikmmiif827j981fy7zvglvz"))
                (patches (search-patches "libretro-dolphin-emu-data.patch"))))
      (source
       (origin
         (inherit (package-source dolphin-emu))
         (method git-fetch)
         (uri (git-reference
                (url "https://github.com/libretro/dolphin")
                (commit commit)))
         (file-name (git-file-name name version))
         (sha256
          (base32
           "15vv3kz1vcsk53m4b19ckx9xx9cx8l0lgpzalpy625iv7qvdcj9m"))
         (modules '((guix build utils)
                    (ice-9 ftw)
                    (ice-9 regex)
                    (srfi srfi-26)))
         (snippet
          #~(begin
              ;; XXX: 'delete-all-but' is copied from the turbovnc package.
              (define (delete-all-but directory . preserve)
                (define (directory? x)
                  (and=> (stat x #f)
                         (compose (cut eq? 'directory <>) stat:type)))
                (with-directory-excursion directory
                  (let* ((pred
                          (negate (cut member <> (append '("." "..") preserve))))
                         (items (scandir "." pred)))
                    (for-each (lambda (item)
                                (if (directory? item)
                                    (delete-file-recursively item)
                                    (delete-file item)))
                              items))))

              ;; Clean up the source from bundled libraries we don't need.
              (delete-all-but "Externals"
                              ;; XXX: The build system is currently hard-coded
                              ;; to rely on these bundled copies.
                              "Bochs_disasm"
                              "FreeSurround"
                              "Libretro"
                              "cpp-optparse"
                              "glslang"
                              "imgui"
                              "picojson")
              (for-each delete-file
                        (find-files
                         "."
                         (lambda (file _)
                           (and (string-match "\\.(bin|dsy|exe|jar|rar)$" file)
                                ;; Preserve the important wc24 .bin
                                ;; configuration *data* files.
                                (not (member (basename file)
                                             '("misc.bin"
                                               "nwc24dl.bin"
                                               "nwc24fl.bin"
                                               "nwc24fls.bin")))))))))
         (patches
          (search-patches "libretro-dolphin-emu-data.patch"
                          "libretro-dolphin-emu-gc-font-tool.patch"
                          "libretro-dolphin-emu-libusb-assert.patch"
                          "libretro-dolphin-emu-vulkan-headers.patch"))))
      (arguments
       (substitute-keyword-arguments (package-arguments dolphin-emu)
         ((#:configure-flags flags ''())
          #~(cons "-DLIBRETRO=ON" #$flags))
          #~(cons* (string-append "-DCMAKE_CXX_FLAGS="
                                  "-I" (search-input-directory
                                        %build-inputs "include/soundtouch"))
                   "-DLIBRETRO=ON"
                   "-DUSE_SHARED_ENET=ON"
                   #$flags))
         ((#:phases phases '%standard-phases)
          #~(modify-phases #$phases
              (add-after 'unpack 'link-unittest-to-gtest
                (lambda _
                  ;; Otherwise, linking with the tests with gtest_main fails
                  ;; with a "DSO missing from command line"
                  (substitute* "Source/UnitTests/CMakeLists.txt"
                    (("PRIVATE core uicommon gtest_main" all)
                     (string-append all " gtest")))))
              (add-after 'unpack 'deregister-bundled-sources
                (lambda _
                  (substitute* "CMakeLists.txt"
                    ((".*add_subdirectory.*Externals/curl.*") "")
                    ((".*add_subdirectory.*Externals/libpng.*") ""))))
                    ((".*add_subdirectory.*Externals/gtest.*") "")
                    ((".*add_subdirectory.*Externals/libpng.*") "")
                    ((".*add_subdirectory.*Externals/soundtouch.*") "")
                    ((".*add_subdirectory.*Externals/xxhash.*") ""))))
              (replace 'install
                (lambda _
                  (install-file "dolphin_libretro.so"


@@ 581,11 629,45 @@ turbo speed, networked multiplayer, and graphical enhancements.")
                    (copy-recursively "../source/Data/Sys"
                                      (string-append sysdir "/Sys")))))))))
      (inputs
       ;; Delete large and extraneous inputs.
       (modify-inputs (package-inputs dolphin-emu)
         (delete "ffmpeg"
                 "gtk+"
                 "qtbase")))
       (list alsa-lib
             ao
             bluez
             bzip2
             cubeb
             curl
             enet
             eudev
             fmt
             font-wqy-microhei
             freetype
             glew
             glib
             glu
             googletest
             hidapi
             libevdev
             libpng
             libusb
             libx11
             libxi
             libxrandr
             lzo
             mbedtls-lts
             mesa
             miniupnpc
             minizip-ng-compat
             openal
             pugixml
             pulseaudio
             sdl2
             sfml-2
             soil
             soundtouch-1/integer-samples
             xxhash
             vulkan-loader
             vulkan-headers
             zlib
             `(,zstd "lib")))
      (synopsis "Libretro port of Dolphin, the Nintendo Wii/GameCube emulator"))))

(define-public dosbox

D gnu/packages/patches/dolphin-emu-data.patch => gnu/packages/patches/dolphin-emu-data.patch +0 -15
@@ 1,15 0,0 @@
Resolve a hang in the menu of this game.

Upstream-status: https://github.com/dolphin-emu/dolphin/pull/13285

diff --git a/Data/Sys/GameSettings/GWR.ini b/Data/Sys/GameSettings/GWR.ini
new file mode 100644
index 0000000000..fdbc0c312f
--- /dev/null
+++ b/Data/Sys/GameSettings/GWR.ini
@@ -0,0 +1,5 @@
+# GWR - WAVE RACE / BLUE STORM
+
+[Core]
+# Disable multi-threading to avoid a hang in the game menu.
+CPUThread = False

A gnu/packages/patches/dolphin-emu-unbundle-tinygltf.patch => gnu/packages/patches/dolphin-emu-unbundle-tinygltf.patch +80 -0
@@ 0,0 1,80 @@
Upstream-status: https://github.com/dolphin-emu/dolphin/pull/13824

diff --git a/CMake/DolphinLibraryTools.cmake b/CMake/DolphinLibraryTools.cmake
index 4c395a8ef9..efa0d6a9e2 100644
--- a/CMake/DolphinLibraryTools.cmake
+++ b/CMake/DolphinLibraryTools.cmake
@@ -1,14 +1,3 @@
-# like add_library(new ALIAS old) but avoids add_library cannot create ALIAS target "new" because target "old" is imported but not globally visible. on older cmake
-# This can be replaced with a direct alias call once our minimum is cmake 3.18
-function(dolphin_alias_library new old)
-  string(REPLACE "::" "" library_no_namespace ${old})
-  if (NOT TARGET _alias_${library_no_namespace})
-    add_library(_alias_${library_no_namespace} INTERFACE)
-    target_link_libraries(_alias_${library_no_namespace} INTERFACE ${old})
-  endif()
-  add_library(${new} ALIAS _alias_${library_no_namespace})
-endfunction()
-
 # Makes an imported target if it doesn't exist.  Useful for when find scripts from older versions of cmake don't make the targets you need
 function(dolphin_make_imported_target_if_missing target lib)
   if(${lib}_FOUND AND NOT TARGET ${target})
@@ -85,7 +74,7 @@ function(dolphin_find_optional_system_library_pkgconfig library search alias bun
   endif()
   if(${library}_FOUND)
     message(STATUS "Using system ${library}")
-    dolphin_alias_library(${alias} PkgConfig::${library})
+    add_library(${alias} ALIAS PkgConfig::${library})
     set(${library}_TYPE "System" PARENT_SCOPE)
   else()
     dolphin_add_bundled_library(${library} ${use_system} ${bundled_path})
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c277e2a10a..67b72179f3 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,7 +1,7 @@
 ########################################
 # General setup
 #
-cmake_minimum_required(VERSION 3.13)
+cmake_minimum_required(VERSION 3.18)
 
 cmake_policy(SET CMP0079 NEW) # let target_link_libraries() link to a target defined in a different directory
 cmake_policy(SET CMP0080 OLD) # allow using BundleUtilities at configure time
@@ -657,7 +657,11 @@ add_subdirectory(Externals/glslang)
 if(WIN32 OR APPLE)
   add_subdirectory(Externals/spirv_cross)
 endif()
-add_subdirectory(Externals/tinygltf)
+
+dolphin_find_optional_system_library(TinyGLTF Externals/tinygltf)
+if(NOT DEFINED tinygltf)
+  add_library(tinygltf ALIAS tinygltf::tinygltf) # using system library
+endif()
 
 if(ENABLE_VULKAN)
   add_definitions(-DHAS_VULKAN)
diff --git a/Externals/tinygltf/CMakeLists.txt b/Externals/tinygltf/CMakeLists.txt
index 0d86268bbe..9e6a99c6f8 100644
--- a/Externals/tinygltf/CMakeLists.txt
+++ b/Externals/tinygltf/CMakeLists.txt
@@ -7,5 +7,5 @@ if (NOT MSVC)
 endif()
 target_sources(tinygltf PRIVATE
   tinygltf/tiny_gltf.cc)
-target_include_directories(tinygltf INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
+target_include_directories(tinygltf INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/tinygltf)
 dolphin_disable_warnings(tinygltf)
diff --git a/Source/Core/VideoCommon/Assets/MeshAsset.cpp b/Source/Core/VideoCommon/Assets/MeshAsset.cpp
index bde8c8aab6..13eb2b4448 100644
--- a/Source/Core/VideoCommon/Assets/MeshAsset.cpp
+++ b/Source/Core/VideoCommon/Assets/MeshAsset.cpp
@@ -7,7 +7,7 @@
 #include <array>
 #include <utility>
 
-#include <tinygltf/tiny_gltf.h>
+#include <tiny_gltf.h>
 
 #include "Common/IOFile.h"
 #include "Common/Logging/Log.h"

A gnu/packages/patches/dolphin-emu-unbundle-watcher.patch => gnu/packages/patches/dolphin-emu-unbundle-watcher.patch +50 -0
@@ 0,0 1,50 @@
Upstream-status: https://github.com/dolphin-emu/dolphin/pull/13823

diff --git a/CMake/DolphinLibraryTools.cmake b/CMake/DolphinLibraryTools.cmake
index 4c395a8ef9..fb806b1b90 100644
--- a/CMake/DolphinLibraryTools.cmake
+++ b/CMake/DolphinLibraryTools.cmake
@@ -92,3 +92,30 @@ function(dolphin_find_optional_system_library_pkgconfig library search alias bun
     set(${library}_TYPE "Bundled" PARENT_SCOPE)
   endif()
 endfunction()
+
+# This can be used for header-only libraries that doesn't offer a
+# pkg-config or CMake file. It uses CMake's find_file. LIBRARY is the
+# name of the library providing it, INCLUDE is the header file name
+# without its installation prefix (e.g. "wtr/watcher.hpp") while
+# BUNDLED_PATH is the root directory of the bundled library.
+function(dolphin_find_optional_system_include library include bundled_path)
+  dolphin_optional_system_library(use_system ${library})
+  string(TOUPPER ${library} upperlib)
+  if(use_system)
+    find_file(${library}_INCLUDE ${include})
+    if((NOT ${library}_INCLUDE) AND (NOT ${use_system} STREQUAL "AUTO"))
+      message(FATAL_ERROR "No system ${library} headers found. \
+Please install it or set USE_SYSTEM_${upperlib} to AUTO or OFF.")
+    endif()
+  endif()
+  if(${library}_INCLUDE)
+    message(STATUS "Using system ${library} headers")
+    set(${library}_TYPE "System" PARENT_SCOPE)
+    add_library(${library} INTERFACE IMPORTED GLOBAL)
+    set_target_properties(${library} PROPERTIES
+      INTERFACE_INCLUDE_DIRECTORIES ${${library}_INCLUDE})
+  else()
+    dolphin_add_bundled_library(${library} ${use_system} ${bundled_path})
+    set(${library}_TYPE "Bundled" PARENT_SCOPE)
+  endif()
+endfunction()
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c277e2a10a..12b1c36ef0 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -786,7 +786,7 @@ if (USE_RETRO_ACHIEVEMENTS)
 	add_subdirectory(Externals/rcheevos)
 endif()
 
-add_subdirectory(Externals/watcher)
+dolphin_find_optional_system_include(watcher wtr/watcher.hpp Externals/watcher)
 
 ########################################
 # Pre-build events: Define configuration variables and write SCM info header

A gnu/packages/patches/libretro-dolphin-emu-gc-font-tool.patch => gnu/packages/patches/libretro-dolphin-emu-gc-font-tool.patch +17 -0
@@ 0,0 1,17 @@
This patch is already merged in dolphin.

It'll appear in libretro-dolphin whenever it is rebased on top of current
dolphin source.

diff --git a/docs/gc-font-tool.cpp b/docs/gc-font-tool.cpp
index f09964609a..c43496d2fa 100644
--- a/docs/gc-font-tool.cpp
+++ b/docs/gc-font-tool.cpp
@@ -76,6 +76,7 @@
 // Font data is encoded in 2 bit greyscale and in 8x8 blocks.
 
 #include <cerrno>
+#include <cstdint>
 #include <cstring>
 #include <fstream>
 #include <iostream>

A gnu/packages/patches/libretro-dolphin-emu-libusb-assert.patch => gnu/packages/patches/libretro-dolphin-emu-libusb-assert.patch +33 -0
@@ 0,0 1,33 @@
This patch is already merged in dolphin.

It'll appear in libretro-dolphin whenever it is rebased on top of current
dolphin source.

diff --git a/Source/Core/Core/LibusbUtils.cpp b/Source/Core/Core/LibusbUtils.cpp
index a4083e2d06..1ef9777e71 100644
--- a/Source/Core/Core/LibusbUtils.cpp
+++ b/Source/Core/Core/LibusbUtils.cpp
@@ -9,8 +9,8 @@
 #include <libusb.h>
 #endif
 
-#include "Common/Assert.h"
 #include "Common/Flag.h"
+#include "Common/Logging/Log.h"
 #include "Common/Thread.h"
 #include "Core/LibusbUtils.h"
 
@@ -23,9 +23,12 @@ public:
   Impl()
   {
     const int ret = libusb_init(&m_context);
-    ASSERT_MSG(IOS_USB, ret == LIBUSB_SUCCESS, "Failed to init libusb: %s", libusb_error_name(ret));
     if (ret != LIBUSB_SUCCESS)
+    {
+      ERROR_LOG(IOS_USB, "Failed to init libusb: %s", libusb_error_name(ret));
       return;
+    }
+
 
 #ifdef _WIN32
     libusb_set_option(m_context, LIBUSB_OPTION_USE_USBDK);

A gnu/packages/patches/libretro-dolphin-emu-vulkan-headers.patch => gnu/packages/patches/libretro-dolphin-emu-vulkan-headers.patch +16 -0
@@ 0,0 1,16 @@
Partial backport from dolphin commit
8e3dbe9671afa631e7a64496f5bfcb2a8206f152 ("Vulkan: update Vulkan headers to v1.3.204.")

diff --git a/Source/Core/VideoBackends/Vulkan/SwapChain.h b/Source/Core/VideoBackends/Vulkan/SwapChain.h
index 0077a93ec1..d83ee57051 100644
--- a/Source/Core/VideoBackends/Vulkan/SwapChain.h
+++ b/Source/Core/VideoBackends/Vulkan/SwapChain.h
@@ -94,7 +94,7 @@ private:
   WindowSystemInfo m_wsi;
   VkSurfaceKHR m_surface = VK_NULL_HANDLE;
   VkSurfaceFormatKHR m_surface_format = {};
-  VkPresentModeKHR m_present_mode = VK_PRESENT_MODE_RANGE_SIZE_KHR;
+  VkPresentModeKHR m_present_mode = VK_PRESENT_MODE_IMMEDIATE_KHR;
   AbstractTextureFormat m_texture_format = AbstractTextureFormat::Undefined;
   bool m_vsync_enabled = false;
   bool m_fullscreen_supported = false;