31 stdenv.mkDerivation (finalAttrs: {
35 src = fetchFromGitHub {
36 owner = "harbourmasters";
38 rev = "refs/tags/${finalAttrs.version}";
39 hash = "sha256-bA+Bm7M6udeZLpFhGa8fCtagfYBeRxWWqFuAj62XwGQ=";
40 fetchSubmodules = true;
47 # This would get fetched at build time otherwise, see:
48 # https://github.com/HarbourMasters/Shipwright/blob/e46c60a7a1396374e23f7a1f7122ddf9efcadff7/soh/CMakeLists.txt#L736
49 gamecontrollerdb = fetchurl {
50 name = "gamecontrollerdb.txt";
51 url = "https://raw.githubusercontent.com/gabomdq/SDL_GameControllerDB/075c1549075ef89a397fd7e0663d21e53a2485fd/gamecontrollerdb.txt";
52 hash = "sha256-atjc0t921l6JSUAd/Yk7uup2R7mCp5ivAh6Dr7HBY7I=";
62 ] ++ lib.optionals stdenv.hostPlatform.isLinux [
65 ] ++ lib.optionals stdenv.hostPlatform.isDarwin [
76 ] ++ lib.optionals stdenv.hostPlatform.isLinux [
85 ] ++ lib.optional stdenv.hostPlatform.isDarwin apple-sdk_11;
88 (lib.cmakeBool "NON_PORTABLE" true)
89 (lib.cmakeFeature "CMAKE_INSTALL_PREFIX" "${placeholder "out"}/lib")
92 env.NIX_CFLAGS_COMPILE =
93 lib.optionalString stdenv.hostPlatform.isDarwin "-Wno-int-conversion -Wno-implicit-int";
97 # Linking fails without this
98 hardeningDisable = [ "format" ];
101 cp ${finalAttrs.gamecontrollerdb} ${finalAttrs.gamecontrollerdb.name}
103 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}
107 preInstall = lib.optionalString stdenv.hostPlatform.isLinux ''
108 # Cmake likes it here for its install paths
109 cp ../OTRExporter/soh.otr ..
110 '' + lib.optionalString stdenv.hostPlatform.isDarwin ''
111 cp ../OTRExporter/soh.otr soh/soh.otr
114 postInstall = lib.optionalString stdenv.hostPlatform.isLinux ''
116 ln -s $out/lib/soh.elf $out/bin/soh
117 install -Dm644 ../soh/macosx/sohIcon.png $out/share/pixmaps/soh.png
118 '' + lib.optionalString stdenv.hostPlatform.isDarwin ''
119 # Recreate the macOS bundle (without using cpack)
120 # We mirror the structure of the bundle distributed by the project
122 mkdir -p $out/Applications/soh.app/Contents
123 cp $src/soh/macosx/Info.plist.in $out/Applications/soh.app/Contents/Info.plist
124 substituteInPlace $out/Applications/soh.app/Contents/Info.plist \
125 --replace-fail "@CMAKE_PROJECT_VERSION@" "${finalAttrs.version}"
127 mv $out/MacOS $out/Applications/soh.app/Contents/MacOS
130 cp $src/soh/macosx/soh-macos.sh.in $out/Applications/soh.app/Contents/MacOS/soh
131 chmod +x $out/Applications/soh.app/Contents/MacOS/soh
132 patchShebangs $out/Applications/soh.app/Contents/MacOS/soh
134 # "lib" contains all resources that are in "Resources" in the official bundle.
135 # We move them to the right place and symlink them back to $out/lib,
136 # as that's where the game expects them.
137 mv $out/Resources $out/Applications/soh.app/Contents/Resources
138 mv $out/lib/** $out/Applications/soh.app/Contents/Resources
140 ln -s $out/Applications/soh.app/Contents/Resources $out/lib
143 cp -r ../build/macosx/soh.icns $out/Applications/soh.app/Contents/Resources/soh.icns
146 install_name_tool -change @executable_path/../Frameworks/libSDL2-2.0.0.dylib \
147 ${SDL2}/lib/libSDL2-2.0.0.dylib \
148 $out/Applications/soh.app/Contents/Resources/soh-macos
149 install_name_tool -change @executable_path/../Frameworks/libGLEW.2.2.0.dylib \
150 ${glew}/lib/libGLEW.2.2.0.dylib \
151 $out/Applications/soh.app/Contents/Resources/soh-macos
152 install_name_tool -change @executable_path/../Frameworks/libpng16.16.dylib \
153 ${libpng}/lib/libpng16.16.dylib \
154 $out/Applications/soh.app/Contents/Resources/soh-macos
157 codesign -f -s - $out/Applications/soh.app/Contents/Resources/soh-macos
160 fixupPhase = lib.optionalString stdenv.hostPlatform.isLinux ''
161 wrapProgram $out/lib/soh.elf --prefix PATH ":" ${lib.makeBinPath [ zenity ]}
169 comment = finalAttrs.meta.description;
170 genericName = "Ship of Harkinian";
172 categories = [ "Game" ];
177 homepage = "https://github.com/HarbourMasters/Shipwright";
178 description = "A PC port of Ocarina of Time with modern controls, widescreen, high-resolution, and more";
180 platforms = [ "x86_64-linux" ] ++ lib.platforms.darwin;
181 maintainers = with lib.maintainers; [ j0lol matteopacini ];
182 license = with lib.licenses; [
183 # OTRExporter, OTRGui, ZAPDTR, libultraship
185 # Ship of Harkinian itself