From 09db531e79e77dda92af467106ab90e6644df6c2 Mon Sep 17 00:00:00 2001 From: qubitnano <146656568+qubitnano@users.noreply.github.com> Date: Mon, 2 Dec 2024 21:59:26 -0500 Subject: [PATCH 1/4] shipwright: 8.0.6 -> 9.0.2 --- pkgs/by-name/sh/shipwright/darwin-fixes.patch | 40 ++--- .../disable-downloading-stb_image.patch | 16 ++ pkgs/by-name/sh/shipwright/package.nix | 147 +++++++++++++----- 3 files changed, 147 insertions(+), 56 deletions(-) create mode 100644 pkgs/by-name/sh/shipwright/disable-downloading-stb_image.patch diff --git a/pkgs/by-name/sh/shipwright/darwin-fixes.patch b/pkgs/by-name/sh/shipwright/darwin-fixes.patch index ae5e936603dd..de9135876a22 100644 --- a/pkgs/by-name/sh/shipwright/darwin-fixes.patch +++ b/pkgs/by-name/sh/shipwright/darwin-fixes.patch @@ -1,37 +1,37 @@ diff --git a/CMakeLists.txt b/CMakeLists.txt -index 2c8644af..157758c9 100644 +index 2771ee8c..0702adad 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt -@@ -166,17 +166,13 @@ endif() +@@ -250,17 +250,13 @@ endif() if(CMAKE_SYSTEM_NAME MATCHES "Darwin") add_custom_target(CreateOSXIcons COMMAND mkdir -p ${CMAKE_BINARY_DIR}/macosx/soh.iconset -- COMMAND sips -z 16 16 soh/macosx/sohIcon.png --out ${CMAKE_BINARY_DIR}/macosx/soh.iconset/icon_16x16.png -- COMMAND sips -z 32 32 soh/macosx/sohIcon.png --out ${CMAKE_BINARY_DIR}/macosx/soh.iconset/icon_16x16@2x.png -- COMMAND sips -z 32 32 soh/macosx/sohIcon.png --out ${CMAKE_BINARY_DIR}/macosx/soh.iconset/icon_32x32.png -- COMMAND sips -z 64 64 soh/macosx/sohIcon.png --out ${CMAKE_BINARY_DIR}/macosx/soh.iconset/icon_32x32@2x.png -- COMMAND sips -z 128 128 soh/macosx/sohIcon.png --out ${CMAKE_BINARY_DIR}/macosx/soh.iconset/icon_128x128.png -- COMMAND sips -z 256 256 soh/macosx/sohIcon.png --out ${CMAKE_BINARY_DIR}/macosx/soh.iconset/icon_128x128@2x.png -- COMMAND sips -z 256 256 soh/macosx/sohIcon.png --out ${CMAKE_BINARY_DIR}/macosx/soh.iconset/icon_256x256.png -- COMMAND sips -z 512 512 soh/macosx/sohIcon.png --out ${CMAKE_BINARY_DIR}/macosx/soh.iconset/icon_256x256@2x.png -- COMMAND sips -z 512 512 soh/macosx/sohIcon.png --out ${CMAKE_BINARY_DIR}/macosx/soh.iconset/icon_512x512.png -- COMMAND cp soh/macosx/sohIcon.png ${CMAKE_BINARY_DIR}/macosx/soh.iconset/icon_512x512@2x.png +- COMMAND sips -z 16 16 ${CMAKE_SOURCE_DIR}/soh/macosx/sohIcon.png --out ${CMAKE_BINARY_DIR}/macosx/soh.iconset/icon_16x16.png +- COMMAND sips -z 32 32 ${CMAKE_SOURCE_DIR}/soh/macosx/sohIcon.png --out ${CMAKE_BINARY_DIR}/macosx/soh.iconset/icon_16x16@2x.png +- COMMAND sips -z 32 32 ${CMAKE_SOURCE_DIR}/soh/macosx/sohIcon.png --out ${CMAKE_BINARY_DIR}/macosx/soh.iconset/icon_32x32.png +- COMMAND sips -z 64 64 ${CMAKE_SOURCE_DIR}/soh/macosx/sohIcon.png --out ${CMAKE_BINARY_DIR}/macosx/soh.iconset/icon_32x32@2x.png +- COMMAND sips -z 128 128 ${CMAKE_SOURCE_DIR}/soh/macosx/sohIcon.png --out ${CMAKE_BINARY_DIR}/macosx/soh.iconset/icon_128x128.png +- COMMAND sips -z 256 256 ${CMAKE_SOURCE_DIR}/soh/macosx/sohIcon.png --out ${CMAKE_BINARY_DIR}/macosx/soh.iconset/icon_128x128@2x.png +- COMMAND sips -z 256 256 ${CMAKE_SOURCE_DIR}/soh/macosx/sohIcon.png --out ${CMAKE_BINARY_DIR}/macosx/soh.iconset/icon_256x256.png +- COMMAND sips -z 512 512 ${CMAKE_SOURCE_DIR}/soh/macosx/sohIcon.png --out ${CMAKE_BINARY_DIR}/macosx/soh.iconset/icon_256x256@2x.png +- COMMAND sips -z 512 512 ${CMAKE_SOURCE_DIR}/soh/macosx/sohIcon.png --out ${CMAKE_BINARY_DIR}/macosx/soh.iconset/icon_512x512.png +- COMMAND cp ${CMAKE_SOURCE_DIR}/soh/macosx/sohIcon.png ${CMAKE_BINARY_DIR}/macosx/soh.iconset/icon_512x512@2x.png - COMMAND iconutil -c icns -o ${CMAKE_BINARY_DIR}/macosx/soh.icns ${CMAKE_BINARY_DIR}/macosx/soh.iconset -+ COMMAND convert soh/macosx/sohIcon.png -resize 16x16 ${CMAKE_BINARY_DIR}/macosx/soh.iconset/icon_16.png -+ COMMAND convert soh/macosx/sohIcon.png -resize 32x32 ${CMAKE_BINARY_DIR}/macosx/soh.iconset/icon_32.png -+ COMMAND convert soh/macosx/sohIcon.png -resize 64x64 ${CMAKE_BINARY_DIR}/macosx/soh.iconset/icon_64.png -+ COMMAND convert soh/macosx/sohIcon.png -resize 128x128 ${CMAKE_BINARY_DIR}/macosx/soh.iconset/icon_128.png -+ COMMAND convert soh/macosx/sohIcon.png -resize 256x256 ${CMAKE_BINARY_DIR}/macosx/soh.iconset/icon_256.png -+ COMMAND convert soh/macosx/sohIcon.png -resize 512x512 ${CMAKE_BINARY_DIR}/macosx/soh.iconset/icon_512.png ++ COMMAND convert ${CMAKE_SOURCE_DIR}/soh/macosx/sohIcon.png -resize 16x16 ${CMAKE_BINARY_DIR}/macosx/soh.iconset/icon_16.png ++ COMMAND convert ${CMAKE_SOURCE_DIR}/soh/macosx/sohIcon.png -resize 32x32 ${CMAKE_BINARY_DIR}/macosx/soh.iconset/icon_32.png ++ COMMAND convert ${CMAKE_SOURCE_DIR}/soh/macosx/sohIcon.png -resize 64x64 ${CMAKE_BINARY_DIR}/macosx/soh.iconset/icon_64.png ++ COMMAND convert ${CMAKE_SOURCE_DIR}/soh/macosx/sohIcon.png -resize 128x128 ${CMAKE_BINARY_DIR}/macosx/soh.iconset/icon_128.png ++ COMMAND convert ${CMAKE_SOURCE_DIR}/soh/macosx/sohIcon.png -resize 256x256 ${CMAKE_BINARY_DIR}/macosx/soh.iconset/icon_256.png ++ COMMAND convert ${CMAKE_SOURCE_DIR}/soh/macosx/sohIcon.png -resize 512x512 ${CMAKE_BINARY_DIR}/macosx/soh.iconset/icon_512.png + COMMAND png2icns ${CMAKE_BINARY_DIR}/macosx/soh.icns ${CMAKE_BINARY_DIR}/macosx/soh.iconset/icon_{16,32,64,128,256,512}.png WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} COMMENT "Creating OSX icons ..." ) -@@ -201,7 +197,6 @@ install(DIRECTORY ${CMAKE_BINARY_DIR}/assets +@@ -288,7 +284,6 @@ INSTALL(CODE "FILE(RENAME \${CMAKE_INSTALL_PREFIX}/../MacOS/soh-macos \${CMAKE_I install(CODE " include(BundleUtilities) -- fixup_bundle(\"\${CMAKE_INSTALL_PREFIX}/soh-macos\" \"\" \"${dirs}\") +- fixup_bundle(\"\${CMAKE_INSTALL_PREFIX}/../MacOS/soh\" \"\" \"${dirs}\") ") endif() diff --git a/pkgs/by-name/sh/shipwright/disable-downloading-stb_image.patch b/pkgs/by-name/sh/shipwright/disable-downloading-stb_image.patch new file mode 100644 index 000000000000..eade8db90a7b --- /dev/null +++ b/pkgs/by-name/sh/shipwright/disable-downloading-stb_image.patch @@ -0,0 +1,16 @@ +Submodule libultraship contains modified content +diff --git a/libultraship/cmake/dependencies/common.cmake b/libultraship/cmake/dependencies/common.cmake +index 596158c..c62d7b2 100644 +--- a/libultraship/cmake/dependencies/common.cmake ++++ b/libultraship/cmake/dependencies/common.cmake +@@ -47,10 +47,6 @@ set(stormlib_optimizations_patch git apply ${CMAKE_CURRENT_SOURCE_DIR}/cmake/dep + endif() + + #=================== STB =================== +-set(STB_DIR ${CMAKE_BINARY_DIR}/_deps/stb) +-file(DOWNLOAD "https://github.com/nothings/stb/raw/0bc88af4de5fb022db643c2d8e549a0927749354/stb_image.h" "${STB_DIR}/stb_image.h") +-file(WRITE "${STB_DIR}/stb_impl.c" "#define STB_IMAGE_IMPLEMENTATION\n#include \"stb_image.h\"") +- + add_library(stb STATIC) + + target_sources(stb PRIVATE diff --git a/pkgs/by-name/sh/shipwright/package.nix b/pkgs/by-name/sh/shipwright/package.nix index 3c1511efdb52..5cbd8e1984bf 100644 --- a/pkgs/by-name/sh/shipwright/package.nix +++ b/pkgs/by-name/sh/shipwright/package.nix @@ -10,12 +10,6 @@ copyDesktopItems, makeDesktopItem, python3, - libX11, - libXrandr, - libXinerama, - libXcursor, - libXi, - libXext, glew, boost, SDL2, @@ -28,36 +22,91 @@ makeWrapper, darwin, libicns, + libzip, + nlohmann_json, + tinyxml-2, + spdlog, + writeTextFile, + shipwright, }: + +let + + # The following would normally get fetched at build time, or a specific version is required + + gamecontrollerdb = fetchFromGitHub { + owner = "mdqinc"; + repo = "SDL_GameControllerDB"; + rev = "a74711e1e87733ccdf02d7020d8fa9e4fa67176e"; + hash = "sha256-rXC4akz9BaKzr/C2CryZC6RGk6+fGVG7RsQryUFUUk0="; + }; + + imgui' = fetchFromGitHub { + owner = "ocornut"; + repo = "imgui"; + tag = "v1.91.6-docking"; + hash = "sha256-28wyzzwXE02W5vbEdRCw2iOF8ONkb3M3Al8XlYBvz1A="; + }; + + libgfxd = fetchFromGitHub { + owner = "glankk"; + repo = "libgfxd"; + rev = "008f73dca8ebc9151b205959b17773a19c5bd0da"; + hash = "sha256-AmHAa3/cQdh7KAMFOtz5TQpcM6FqO9SppmDpKPTjTt8="; + }; + + prism = fetchFromGitHub { + owner = "KiritoDv"; + repo = "prism-processor"; + rev = "fb3f8b4a2d14dfcbae654d0f0e59a73b6f6ca850"; + hash = "sha256-gGdQSpX/TgCNZ0uyIDdnazgVHpAQhl30e+V0aVvTFMM="; + }; + + stb_impl = writeTextFile { + name = "stb_impl.c"; + text = '' + #define STB_IMAGE_IMPLEMENTATION + #include "stb_image.h" + ''; + }; + + stb' = fetchurl { + name = "stb_image.h"; + url = "https://raw.githubusercontent.com/nothings/stb/0bc88af4de5fb022db643c2d8e549a0927749354/stb_image.h"; + hash = "sha256-xUsVponmofMsdeLsI6+kQuPg436JS3PBl00IZ5sg3Vw="; + }; + + stormlib' = fetchFromGitHub { + owner = "ladislav-zezula"; + repo = "StormLib"; + tag = "v9.25"; + hash = "sha256-HTi2FKzKCbRaP13XERUmHkJgw8IfKaRJvsK3+YxFFdc="; + }; + + thread_pool = fetchFromGitHub { + owner = "bshoshany"; + repo = "thread-pool"; + rev = "v4.1.0"; + hash = "sha256-zhRFEmPYNFLqQCfvdAaG5VBNle9Qm8FepIIIrT9sh88="; + }; +in stdenv.mkDerivation (finalAttrs: { pname = "shipwright"; - version = "8.0.6"; + version = "9.0.2"; src = fetchFromGitHub { owner = "harbourmasters"; repo = "shipwright"; tag = finalAttrs.version; - hash = "sha256-bA+Bm7M6udeZLpFhGa8fCtagfYBeRxWWqFuAj62XwGQ="; + hash = "sha256-xmRUUMjQt3CFJ0GxlUsUqmp//XTRWik3jSD4auql7Nk="; fetchSubmodules = true; }; patches = [ ./darwin-fixes.patch - (fetchpatch { - name = "gcc14.patch"; - url = "https://github.com/HarbourMasters/Shipwright/commit/1bc15d5bf3042d4fd64e1952eb68c47a7d5d8061.patch"; - hash = "sha256-OpjP+rGqx56DB4W8yzLkxuxSAQa6oXQqtbQ2cNcFjYQ="; - }) + ./disable-downloading-stb_image.patch ]; - # This would get fetched at build time otherwise, see: - # https://github.com/HarbourMasters/Shipwright/blob/e46c60a7a1396374e23f7a1f7122ddf9efcadff7/soh/CMakeLists.txt#L736 - gamecontrollerdb = fetchurl { - name = "gamecontrollerdb.txt"; - url = "https://raw.githubusercontent.com/gabomdq/SDL_GameControllerDB/075c1549075ef89a397fd7e0663d21e53a2485fd/gamecontrollerdb.txt"; - hash = "sha256-atjc0t921l6JSUAd/Yk7uup2R7mCp5ivAh6Dr7HBY7I="; - }; - nativeBuildInputs = [ cmake @@ -85,19 +134,23 @@ stdenv.mkDerivation (finalAttrs: { libpng ] ++ lib.optionals stdenv.hostPlatform.isLinux [ - libX11 - libXrandr - libXinerama - libXcursor - libXi - libXext libpulseaudio zenity + libzip + nlohmann_json + tinyxml-2 + spdlog ]; cmakeFlags = [ + (lib.cmakeBool "BUILD_REMOTE_CONTROL" true) (lib.cmakeBool "NON_PORTABLE" true) (lib.cmakeFeature "CMAKE_INSTALL_PREFIX" "${placeholder "out"}/lib") + (lib.cmakeFeature "FETCHCONTENT_SOURCE_DIR_IMGUI" "/build/source/build/_deps/imgui-src") + (lib.cmakeFeature "FETCHCONTENT_SOURCE_DIR_LIBGFXD" "${libgfxd}") + (lib.cmakeFeature "FETCHCONTENT_SOURCE_DIR_PRISM" "${prism}") + (lib.cmakeFeature "FETCHCONTENT_SOURCE_DIR_STORMLIB" "/build/source/build/_deps/stormlib-src") + (lib.cmakeFeature "FETCHCONTENT_SOURCE_DIR_THREADPOOL" "${thread_pool}") ]; env.NIX_CFLAGS_COMPILE = lib.optionalString stdenv.hostPlatform.isDarwin "-Wno-int-conversion -Wno-implicit-int"; @@ -107,21 +160,43 @@ stdenv.mkDerivation (finalAttrs: { # Linking fails without this hardeningDisable = [ "format" ]; + preConfigure = '' + mkdir stb + cp ${stb'} ./stb/${stb'.name} + cp ${stb_impl} ./stb/${stb_impl.name} + substituteInPlace libultraship/cmake/dependencies/common.cmake \ + --replace-fail "\''${STB_DIR}" "/build/source/stb" + ''; + + postPatch = '' + # use the soh patched deps when building + + mkdir -p ./build/_deps/imgui-src + cp -R --no-preserve=mode,ownership ${imgui'}/* ./build/_deps/imgui-src + pushd ./build/_deps/imgui-src + patch -p1 < ${shipwright.src}/libultraship/cmake/dependencies/patches/imgui-fixes-and-config.patch + popd + + mkdir -p ./build/_deps/stormlib-src + cp -R --no-preserve=mode,ownership ${stormlib'}/* ./build/_deps/stormlib-src + pushd ./build/_deps/stormlib-src + patch -p1 < ${shipwright.src}/libultraship/cmake/dependencies/patches/stormlib-optimizations.patch + popd + + ''; + postBuild = '' - cp ${finalAttrs.gamecontrollerdb} ${finalAttrs.gamecontrollerdb.name} + cp ${gamecontrollerdb}/gamecontrollerdb.txt gamecontrollerdb.txt + mv ../libultraship/src/graphic/Fast3D/shaders ../soh/assets/custom pushd ../OTRExporter python3 ./extract_assets.py -z ../build/ZAPD/ZAPD.out --norom --xml-root ../soh/assets/xml --custom-assets-path ../soh/assets/custom --custom-otr-file soh.otr --port-ver ${finalAttrs.version} popd ''; - preInstall = - lib.optionalString stdenv.hostPlatform.isLinux '' - # Cmake likes it here for its install paths - cp ../OTRExporter/soh.otr .. - '' - + lib.optionalString stdenv.hostPlatform.isDarwin '' - cp ../OTRExporter/soh.otr soh/soh.otr - ''; + preInstall = '' + # Cmake likes it here for its install paths + cp ../OTRExporter/soh.otr soh/soh.otr + ''; postInstall = lib.optionalString stdenv.hostPlatform.isLinux '' From ea7859639368d4f0b1f39cfa783aa137a37ee2b8 Mon Sep 17 00:00:00 2001 From: qubitnano <146656568+qubitnano@users.noreply.github.com> Date: Fri, 4 Apr 2025 17:36:39 -0400 Subject: [PATCH 2/4] shipwright: update darwin dependencies and use applyPatches Added Darwin deps Metal.hpp, a macOS Metal C++ wrapper header library apple-sdk_13 (macOS 13.0+), required by the above spdlog Removed hardcoded "/build/source/*" paths, they do not work on Darwin Rewritten imgui' and stormlib' using applyPatches, so they end up in the nix store, and we don't need to specify absolute paths Simplified postInstallPhase(few things have changed since 8.x.x) Author: Matteo Pacini --- pkgs/by-name/sh/shipwright/package.nix | 120 ++++++++++++------------- 1 file changed, 58 insertions(+), 62 deletions(-) diff --git a/pkgs/by-name/sh/shipwright/package.nix b/pkgs/by-name/sh/shipwright/package.nix index 5cbd8e1984bf..e0b49a975314 100644 --- a/pkgs/by-name/sh/shipwright/package.nix +++ b/pkgs/by-name/sh/shipwright/package.nix @@ -1,4 +1,5 @@ { + apple-sdk_13, stdenv, cmake, lsb-release, @@ -6,7 +7,6 @@ lib, fetchFromGitHub, fetchurl, - fetchpatch, copyDesktopItems, makeDesktopItem, python3, @@ -27,6 +27,8 @@ tinyxml-2, spdlog, writeTextFile, + fixDarwinDylibNames, + applyPatches, shipwright, }: @@ -41,11 +43,16 @@ let hash = "sha256-rXC4akz9BaKzr/C2CryZC6RGk6+fGVG7RsQryUFUUk0="; }; - imgui' = fetchFromGitHub { - owner = "ocornut"; - repo = "imgui"; - tag = "v1.91.6-docking"; - hash = "sha256-28wyzzwXE02W5vbEdRCw2iOF8ONkb3M3Al8XlYBvz1A="; + imgui' = applyPatches { + src = fetchFromGitHub { + owner = "ocornut"; + repo = "imgui"; + tag = "v1.91.6-docking"; + hash = "sha256-28wyzzwXE02W5vbEdRCw2iOF8ONkb3M3Al8XlYBvz1A="; + }; + patches = [ + "${shipwright.src}/libultraship/cmake/dependencies/patches/imgui-fixes-and-config.patch" + ]; }; libgfxd = fetchFromGitHub { @@ -76,19 +83,31 @@ let hash = "sha256-xUsVponmofMsdeLsI6+kQuPg436JS3PBl00IZ5sg3Vw="; }; - stormlib' = fetchFromGitHub { - owner = "ladislav-zezula"; - repo = "StormLib"; - tag = "v9.25"; - hash = "sha256-HTi2FKzKCbRaP13XERUmHkJgw8IfKaRJvsK3+YxFFdc="; + stormlib' = applyPatches { + src = fetchFromGitHub { + owner = "ladislav-zezula"; + repo = "StormLib"; + tag = "v9.25"; + hash = "sha256-HTi2FKzKCbRaP13XERUmHkJgw8IfKaRJvsK3+YxFFdc="; + }; + patches = [ + "${shipwright.src}/libultraship/cmake/dependencies/patches/stormlib-optimizations.patch" + ]; }; thread_pool = fetchFromGitHub { owner = "bshoshany"; repo = "thread-pool"; - rev = "v4.1.0"; + tag = "v4.1.0"; hash = "sha256-zhRFEmPYNFLqQCfvdAaG5VBNle9Qm8FepIIIrT9sh88="; }; + + metalcpp = fetchFromGitHub { + owner = "briaguya-ai"; + repo = "single-header-metal-cpp"; + tag = "macOS13_iOS16"; + hash = "sha256-CSYIpmq478bla2xoPL/cGYKIWAeiORxyFFZr0+ixd7I"; + }; in stdenv.mkDerivation (finalAttrs: { pname = "shipwright"; @@ -123,6 +142,7 @@ stdenv.mkDerivation (finalAttrs: { ++ lib.optionals stdenv.hostPlatform.isDarwin [ libicns darwin.sigtool + fixDarwinDylibNames ]; buildInputs = @@ -132,28 +152,37 @@ stdenv.mkDerivation (finalAttrs: { SDL2 SDL2_net libpng - ] - ++ lib.optionals stdenv.hostPlatform.isLinux [ - libpulseaudio - zenity libzip nlohmann_json tinyxml-2 spdlog + ] + ++ lib.optionals stdenv.hostPlatform.isLinux [ + libpulseaudio + zenity + ] + ++ lib.optionals stdenv.hostPlatform.isDarwin [ + # Metal.hpp requires macOS 13.x min. + apple-sdk_13 ]; - cmakeFlags = [ - (lib.cmakeBool "BUILD_REMOTE_CONTROL" true) - (lib.cmakeBool "NON_PORTABLE" true) - (lib.cmakeFeature "CMAKE_INSTALL_PREFIX" "${placeholder "out"}/lib") - (lib.cmakeFeature "FETCHCONTENT_SOURCE_DIR_IMGUI" "/build/source/build/_deps/imgui-src") - (lib.cmakeFeature "FETCHCONTENT_SOURCE_DIR_LIBGFXD" "${libgfxd}") - (lib.cmakeFeature "FETCHCONTENT_SOURCE_DIR_PRISM" "${prism}") - (lib.cmakeFeature "FETCHCONTENT_SOURCE_DIR_STORMLIB" "/build/source/build/_deps/stormlib-src") - (lib.cmakeFeature "FETCHCONTENT_SOURCE_DIR_THREADPOOL" "${thread_pool}") - ]; + cmakeFlags = + [ + (lib.cmakeBool "BUILD_REMOTE_CONTROL" true) + (lib.cmakeBool "NON_PORTABLE" true) + (lib.cmakeFeature "CMAKE_INSTALL_PREFIX" "${placeholder "out"}/lib") + (lib.cmakeFeature "FETCHCONTENT_SOURCE_DIR_IMGUI" "${imgui'}") + (lib.cmakeFeature "FETCHCONTENT_SOURCE_DIR_LIBGFXD" "${libgfxd}") + (lib.cmakeFeature "FETCHCONTENT_SOURCE_DIR_PRISM" "${prism}") + (lib.cmakeFeature "FETCHCONTENT_SOURCE_DIR_STORMLIB" "${stormlib'}") + (lib.cmakeFeature "FETCHCONTENT_SOURCE_DIR_THREADPOOL" "${thread_pool}") + ] + ++ lib.optionals stdenv.hostPlatform.isDarwin [ + (lib.cmakeFeature "FETCHCONTENT_SOURCE_DIR_METALCPP" "${metalcpp}") + (lib.cmakeFeature "FETCHCONTENT_SOURCE_DIR_SPDLOG" "${spdlog}") + ]; - env.NIX_CFLAGS_COMPILE = lib.optionalString stdenv.hostPlatform.isDarwin "-Wno-int-conversion -Wno-implicit-int"; + env.NIX_CFLAGS_COMPILE = lib.optionalString stdenv.hostPlatform.isDarwin "-Wno-int-conversion -Wno-implicit-int -Wno-elaborated-enum-base"; dontAddPrefix = true; @@ -165,24 +194,7 @@ stdenv.mkDerivation (finalAttrs: { cp ${stb'} ./stb/${stb'.name} cp ${stb_impl} ./stb/${stb_impl.name} substituteInPlace libultraship/cmake/dependencies/common.cmake \ - --replace-fail "\''${STB_DIR}" "/build/source/stb" - ''; - - postPatch = '' - # use the soh patched deps when building - - mkdir -p ./build/_deps/imgui-src - cp -R --no-preserve=mode,ownership ${imgui'}/* ./build/_deps/imgui-src - pushd ./build/_deps/imgui-src - patch -p1 < ${shipwright.src}/libultraship/cmake/dependencies/patches/imgui-fixes-and-config.patch - popd - - mkdir -p ./build/_deps/stormlib-src - cp -R --no-preserve=mode,ownership ${stormlib'}/* ./build/_deps/stormlib-src - pushd ./build/_deps/stormlib-src - patch -p1 < ${shipwright.src}/libultraship/cmake/dependencies/patches/stormlib-optimizations.patch - popd - + --replace-fail "\''${STB_DIR}" "$(readlink -f ./stb)" ''; postBuild = '' @@ -215,11 +227,6 @@ stdenv.mkDerivation (finalAttrs: { mv $out/MacOS $out/Applications/soh.app/Contents/MacOS - # Wrapper - cp $src/soh/macosx/soh-macos.sh.in $out/Applications/soh.app/Contents/MacOS/soh - chmod +x $out/Applications/soh.app/Contents/MacOS/soh - patchShebangs $out/Applications/soh.app/Contents/MacOS/soh - # "lib" contains all resources that are in "Resources" in the official bundle. # We move them to the right place and symlink them back to $out/lib, # as that's where the game expects them. @@ -231,19 +238,8 @@ stdenv.mkDerivation (finalAttrs: { # Copy icons cp -r ../build/macosx/soh.icns $out/Applications/soh.app/Contents/Resources/soh.icns - # Fix executable - install_name_tool -change @executable_path/../Frameworks/libSDL2-2.0.0.dylib \ - ${SDL2}/lib/libSDL2-2.0.0.dylib \ - $out/Applications/soh.app/Contents/Resources/soh-macos - install_name_tool -change @executable_path/../Frameworks/libGLEW.2.2.0.dylib \ - ${glew}/lib/libGLEW.2.2.0.dylib \ - $out/Applications/soh.app/Contents/Resources/soh-macos - install_name_tool -change @executable_path/../Frameworks/libpng16.16.dylib \ - ${libpng}/lib/libpng16.16.dylib \ - $out/Applications/soh.app/Contents/Resources/soh-macos - # Codesign (ad-hoc) - codesign -f -s - $out/Applications/soh.app/Contents/Resources/soh-macos + codesign -f -s - $out/Applications/soh.app/Contents/MacOS/soh ''; fixupPhase = lib.optionalString stdenv.hostPlatform.isLinux '' From 10218c015dcdee2a1c0118f3e838ed11ca891e8a Mon Sep 17 00:00:00 2001 From: qubitnano <146656568+qubitnano@users.noreply.github.com> Date: Tue, 8 Apr 2025 00:14:39 -0400 Subject: [PATCH 3/4] shipwright: include git build details These git commands can't run in the sandbox, so populate them ourselves --- pkgs/by-name/sh/shipwright/package.nix | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/pkgs/by-name/sh/shipwright/package.nix b/pkgs/by-name/sh/shipwright/package.nix index e0b49a975314..91bc93f90f6b 100644 --- a/pkgs/by-name/sh/shipwright/package.nix +++ b/pkgs/by-name/sh/shipwright/package.nix @@ -119,6 +119,14 @@ stdenv.mkDerivation (finalAttrs: { tag = finalAttrs.version; hash = "sha256-xmRUUMjQt3CFJ0GxlUsUqmp//XTRWik3jSD4auql7Nk="; fetchSubmodules = true; + deepClone = true; + postFetch = '' + cd $out + git branch --show-current > GIT_BRANCH + git rev-parse --short=7 HEAD > GIT_COMMIT_HASH + git describe --tags --abbrev=0 --exact-match HEAD > GIT_COMMIT_TAG + rm -rf .git + ''; }; patches = [ @@ -197,6 +205,13 @@ stdenv.mkDerivation (finalAttrs: { --replace-fail "\''${STB_DIR}" "$(readlink -f ./stb)" ''; + postPatch = '' + substituteInPlace soh/src/boot/build.c.in \ + --replace-fail "@CMAKE_PROJECT_GIT_BRANCH@" "$(cat GIT_BRANCH)" \ + --replace-fail "@CMAKE_PROJECT_GIT_COMMIT_HASH@" "$(cat GIT_COMMIT_HASH)" \ + --replace-fail "@CMAKE_PROJECT_GIT_COMMIT_TAG@" "$(cat GIT_COMMIT_TAG)" + ''; + postBuild = '' cp ${gamecontrollerdb}/gamecontrollerdb.txt gamecontrollerdb.txt mv ../libultraship/src/graphic/Fast3D/shaders ../soh/assets/custom From 10d91c0f2fb83586c91579ee5981c14f174b237e Mon Sep 17 00:00:00 2001 From: qubitnano <146656568+qubitnano@users.noreply.github.com> Date: Sun, 20 Apr 2025 11:41:09 -0400 Subject: [PATCH 4/4] shipwright: fix dev builds Fallback to empty string for GIT_COMMIT_TAG (this is the behavior of the CMake as well). https://github.com/HarbourMasters/Shipwright/blob/1b6dc13491460462f3a04e56b8fe1a28ada5d2a3/CMakeLists.txt#L68-L70 Grab --port-ver from the CMake cache instead of passing finalAttrs.version. For tagged releases that works fine but the game expects the --port-ver to match the CMake project version even for dev builds so failing to do this will result in the game failing to boot since it thinks there's a version mismatch between the executable and the OTR in the derivation. Author: Sirius902 --- pkgs/by-name/sh/shipwright/package.nix | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkgs/by-name/sh/shipwright/package.nix b/pkgs/by-name/sh/shipwright/package.nix index 91bc93f90f6b..baba8dab5f9c 100644 --- a/pkgs/by-name/sh/shipwright/package.nix +++ b/pkgs/by-name/sh/shipwright/package.nix @@ -124,7 +124,7 @@ stdenv.mkDerivation (finalAttrs: { cd $out git branch --show-current > GIT_BRANCH git rev-parse --short=7 HEAD > GIT_COMMIT_HASH - git describe --tags --abbrev=0 --exact-match HEAD > GIT_COMMIT_TAG + (git describe --tags --abbrev=0 --exact-match HEAD 2>/dev/null || echo "") > GIT_COMMIT_TAG rm -rf .git ''; }; @@ -213,10 +213,11 @@ stdenv.mkDerivation (finalAttrs: { ''; postBuild = '' + port_ver=$(grep CMAKE_PROJECT_VERSION: "$PWD/CMakeCache.txt" | cut -d= -f2) cp ${gamecontrollerdb}/gamecontrollerdb.txt gamecontrollerdb.txt mv ../libultraship/src/graphic/Fast3D/shaders ../soh/assets/custom pushd ../OTRExporter - python3 ./extract_assets.py -z ../build/ZAPD/ZAPD.out --norom --xml-root ../soh/assets/xml --custom-assets-path ../soh/assets/custom --custom-otr-file soh.otr --port-ver ${finalAttrs.version} + python3 ./extract_assets.py -z ../build/ZAPD/ZAPD.out --norom --xml-root ../soh/assets/xml --custom-assets-path ../soh/assets/custom --custom-otr-file soh.otr --port-ver $port_ver popd '';