actual fix for SDL2 needed for input and audio

This commit is contained in:
Tyler Starr 2024-10-22 00:33:32 -07:00
parent b5b78b977e
commit 7a1f293d0c
3 changed files with 51 additions and 5 deletions

View File

@ -4,7 +4,7 @@
final: prev: {
advcpmv = final.callPackage ../pkgs/advcpmv.nix {};
nx_tzdb = final.callPackage ../pkgs/nx_tzdb.nix {};
sudachi = final.kdePackages.callPackage ../pkgs/sudachi.nix {};
sudachi = final.qt6.callPackage ../pkgs/sudachi/default.nix {};
yuzu = final.libsForQt5.callPackage ../pkgs/yuzu.nix {};
gnome-set-panel-monitor = final.callPackage ../pkgs/gnome-set-panel-monitor.nix {};
gnome-fullscreen-to-empty-workspace = final.callPackage ../pkgs/gnome-fullscreen-to-empty-workspace.nix {};

View File

@ -30,14 +30,15 @@
catch2_3,
vulkan-loader,
vulkan-headers,
SDL2,
}:
let
# Derived from externals/nx_tzdb/CMakeLists.txt
nx_tzdb = fetchzip {
url = "https://github.com/lat9nq/tzdb_to_nx/releases/download/221202/221202.zip";
stripRoot = false;
hash = "sha256-YOIElcKTiclem05trZsA3YJReozu/ex7jJAKD6nAMwc=";
stripRoot = false;
};
suyu = fetchFromGitea {
domain = "git.suyu.dev";
@ -58,6 +59,8 @@ stdenv.mkDerivation (finalAttrs: {
stripRoot = false;
};
patches = [ ./sdl2_fix.patch ];
nativeBuildInputs = [
cmake
glslang
@ -71,6 +74,7 @@ stdenv.mkDerivation (finalAttrs: {
boost
fmt
lz4
SDL2
nlohmann_json
qtbase
qtmultimedia
@ -120,9 +124,8 @@ stdenv.mkDerivation (finalAttrs: {
# so "off" means "use system"
"-DSUDACHI_USE_EXTERNAL_VULKAN_HEADERS=OFF"
# Disable SDL2 audio
# Sudachi seems to have a bug that ignores SUDACHI_USE_EXTERNAL_SDL2 flag
"-DENABLE_SDL2=OFF"
# Disable SDL2
# SDL flags are broken somehow in 1.0.11 and fix is hacked in with a patch
# don't use system ffmpeg, sudachi uses internal APIs
"-DSUDACHI_USE_BUNDLED_FFMPEG=ON"

View File

@ -0,0 +1,43 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index ed30417..7c1da0b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -535,34 +535,10 @@ if(ENABLE_QT)
endif()
-# find SDL2 exports a bunch of variables that are needed, so its easier to do this outside of the sudachi_find_package
-if (ENABLE_SDL2 AND NOT USE_SDL2_FROM_EXTERNALS)
- if (SUDACHI_USE_BUNDLED_SDL2)
- # Detect toolchain and platform
- if ((MSVC_VERSION GREATER_EQUAL 1920 AND MSVC_VERSION LESS 1940) AND ARCHITECTURE_x86_64)
- set(SDL2_VER "SDL2-2.28.2")
- else()
- message(FATAL_ERROR "No bundled SDL2 binaries for your toolchain. Disable SUDACHI_USE_BUNDLED_SDL2 and provide your own.")
- endif()
-
- if (DEFINED SDL2_VER)
- download_bundled_external("sdl2/" ${SDL2_VER} SDL2_PREFIX)
- endif()
-
- set(SDL2_FOUND YES)
- set(SDL2_INCLUDE_DIR "${SDL2_PREFIX}/include" CACHE PATH "Path to SDL2 headers")
- set(SDL2_LIBRARY "${SDL2_PREFIX}/lib/x64/SDL2.lib" CACHE PATH "Path to SDL2 library")
- set(SDL2_DLL_DIR "${SDL2_PREFIX}/lib/x64/" CACHE PATH "Path to SDL2.dll")
-
- add_library(SDL2::SDL2 INTERFACE IMPORTED)
- target_link_libraries(SDL2::SDL2 INTERFACE "${SDL2_LIBRARY}")
- target_include_directories(SDL2::SDL2 INTERFACE "${SDL2_INCLUDE_DIR}")
- elseif (USE_SDL2_FROM_EXTERNALS)
- message(STATUS "Using SDL2 from externals.")
- else()
- find_package(SDL2 2.26.4 REQUIRED)
- endif()
-endif()
+# Nixos needs to use packaged SDL2. There is something up with these flags that
+# doesn't currently work properly so here is a quick hack. I'd investigate and
+# report to the dev, but you all are dicks who drove him out. Fuck you all.
+find_package(SDL2 2.26.4 REQUIRED)
if (UNIX AND NOT APPLE AND NOT ANDROID)
find_package(PkgConfig REQUIRED)