From ca5dd27a4d858735de131c6c99d1aebf35dae528 Mon Sep 17 00:00:00 2001 From: TomaSajt <62384384+TomaSajt@users.noreply.github.com> Date: Wed, 3 Apr 2024 18:27:16 +0200 Subject: [PATCH] simple64: init at 2024.09.1 --- .../add-official-server-error-message.patch | 15 +++ .../simple64/dont-use-vosk-and-discord.patch | 37 +++++++ pkgs/by-name/si/simple64/package.nix | 101 ++++++++++++++++++ 3 files changed, 153 insertions(+) create mode 100644 pkgs/by-name/si/simple64/add-official-server-error-message.patch create mode 100644 pkgs/by-name/si/simple64/dont-use-vosk-and-discord.patch create mode 100644 pkgs/by-name/si/simple64/package.nix diff --git a/pkgs/by-name/si/simple64/add-official-server-error-message.patch b/pkgs/by-name/si/simple64/add-official-server-error-message.patch new file mode 100644 index 000000000000..7d37e33c11d1 --- /dev/null +++ b/pkgs/by-name/si/simple64/add-official-server-error-message.patch @@ -0,0 +1,15 @@ +diff --git a/simple64-gui/netplay/joinroom.cpp b/simple64-gui/netplay/joinroom.cpp +index 3b5c34e..68b46f2 100644 +--- a/simple64-gui/netplay/joinroom.cpp ++++ b/simple64-gui/netplay/joinroom.cpp +@@ -308,7 +308,9 @@ void JoinRoom::processTextMessage(QString message) + } + else + { +- msgBox.setText(json.value("message").toString()); ++ QString msg = json.value("message").toString(); ++ if(msg == "Bad authentication code") msg += "
Note: using the official netplay servers is not allowed on unofficial builds.
You can host your own server with `simple64-netplay-server`"; ++ msgBox.setText(msg); + msgBox.exec(); + } + } diff --git a/pkgs/by-name/si/simple64/dont-use-vosk-and-discord.patch b/pkgs/by-name/si/simple64/dont-use-vosk-and-discord.patch new file mode 100644 index 000000000000..69d595cc428a --- /dev/null +++ b/pkgs/by-name/si/simple64/dont-use-vosk-and-discord.patch @@ -0,0 +1,37 @@ +diff --git a/build.sh b/build.sh +index 254a90d..e2d26cf 100644 +--- a/build.sh ++++ b/build.sh +@@ -77,7 +77,7 @@ cmake -G Ninja -DCMAKE_BUILD_TYPE="${RELEASE_TYPE}" .. + cmake --build . + cp simple64-video-parallel.* "${install_dir}" + +-if [[ ! -d "${base_dir}/discord" ]]; then ++if false; then + echo "Downloading Discord SDK" + mkdir -p "${base_dir}/discord" + cd "${base_dir}/discord" +@@ -86,7 +86,7 @@ if [[ ! -d "${base_dir}/discord" ]]; then + rm discord_game_sdk.zip + fi + +-if [[ ! -d "${base_dir}/vosk" ]]; then ++if false; then + mkdir -p "${base_dir}/vosk" + cd "${base_dir}/vosk" + if [[ ${UNAME} == *"MINGW64"* ]]; then +@@ -156,14 +156,6 @@ if [[ ${UNAME} == *"MINGW64"* ]]; then + cp -v "${base_dir}/7z/x64/7za.exe" "${install_dir}" + cp -v "${base_dir}/discord/lib/x86_64/discord_game_sdk.dll" "${install_dir}" + cp -v "${base_dir}/vosk/libvosk.dll" "${install_dir}/vosk.dll" +-else +- cp "${base_dir}/vosk/libvosk.so" "${install_dir}" +- if [[ "${PLATFORM}" == "aarch64" ]]; then +- my_os=linux_aarch64 +- else +- my_os=linux_x86_64 +- cp "${base_dir}/discord/lib/x86_64/discord_game_sdk.so" "${install_dir}/libdiscord_game_sdk.so" +- fi + fi + + if [[ "$1" == "zip" ]]; then diff --git a/pkgs/by-name/si/simple64/package.nix b/pkgs/by-name/si/simple64/package.nix new file mode 100644 index 000000000000..b55c75414161 --- /dev/null +++ b/pkgs/by-name/si/simple64/package.nix @@ -0,0 +1,101 @@ +{ + lib, + stdenv, + fetchFromGitHub, + fetchurl, + writeShellScriptBin, + cmake, + ninja, + pkg-config, + makeWrapper, + zlib, + libpng, + SDL2, + SDL2_net, + hidapi, + qt6, + vulkan-loader, +}: + +let + cheats-json = fetchurl { + url = "https://raw.githubusercontent.com/simple64/cheat-parser/87963b7aca06e0d4632b66bc5ffe7d6b34060f4f/cheats.json"; + hash = "sha256-rS/4Mdi+18C2ywtM5nW2XaJkC1YnKZPc4YdQ3mCfESU="; + }; +in +stdenv.mkDerivation (finalAttrs: { + pname = "simple64"; + version = "2024.09.1"; + + src = fetchFromGitHub { + owner = "simple64"; + repo = "simple64"; + rev = "refs/tags/v${finalAttrs.version}"; + hash = "sha256-t3V7mvHlCP8cOvizR3N9DiCofnSvSHI6U0iXXkaMb34="; + }; + + patches = [ + ./dont-use-vosk-and-discord.patch + ./add-official-server-error-message.patch + ]; + + postPatch = '' + cp ${cheats-json} cheats.json + ''; + + stictDeps = true; + + nativeBuildInputs = [ + qt6.wrapQtAppsHook + cmake + ninja + pkg-config + makeWrapper + # fake git command for version info generator + (writeShellScriptBin "git" "echo ${finalAttrs.src.rev}") + ]; + + buildInputs = [ + zlib + libpng + SDL2 + SDL2_net + hidapi + qt6.qtbase + qt6.qtwebsockets + ]; + + dontUseCmakeConfigure = true; + + dontWrapQtApps = true; + + buildPhase = '' + runHook preInstall + + sh build.sh + + runHook postInstall + ''; + + installPhase = '' + runHook preInstall + + mkdir -p $out/share/simple64 $out/bin + cp -r simple64/* $out/share/simple64 + + makeWrapper $out/share/simple64/simple64-gui $out/bin/simple64-gui \ + --prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath [ vulkan-loader ]} \ + "''${qtWrapperArgs[@]}" + + runHook postInstall + ''; + + meta = { + description = "Easy to use N64 emulator"; + homepage = "https://simple64.github.io"; + license = lib.licenses.gpl3Only; + mainProgram = "simple64-gui"; + maintainers = with lib.maintainers; [ tomasajt ]; + platforms = lib.platforms.linux; + }; +})