python312Packages.types-aiobotocore: 2.15.2 -> 2.15.2.post3 (#361801)
[NixPkgs.git] / pkgs / by-name / sh / shipwright / package.nix
blobee23cbc332bf1f8a78dd91164b0c43a63bbf8a2a
1 { stdenv
2 , cmake
3 , lsb-release
4 , ninja
5 , lib
6 , fetchFromGitHub
7 , fetchurl
8 , copyDesktopItems
9 , makeDesktopItem
10 , python3
11 , libX11
12 , libXrandr
13 , libXinerama
14 , libXcursor
15 , libXi
16 , libXext
17 , glew
18 , boost
19 , SDL2
20 , SDL2_net
21 , pkg-config
22 , libpulseaudio
23 , libpng
24 , imagemagick
25 , zenity
26 , makeWrapper
27 , darwin
28 , apple-sdk_11
29 , libicns
31 stdenv.mkDerivation (finalAttrs: {
32   pname = "shipwright";
33   version = "8.0.6";
35   src = fetchFromGitHub {
36     owner = "harbourmasters";
37     repo = "shipwright";
38     rev = "refs/tags/${finalAttrs.version}";
39     hash = "sha256-bA+Bm7M6udeZLpFhGa8fCtagfYBeRxWWqFuAj62XwGQ=";
40     fetchSubmodules = true;
41   };
43   patches = [
44     ./darwin-fixes.patch
45   ];
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=";
53   };
55   nativeBuildInputs = [
56     cmake
57     ninja
58     pkg-config
59     python3
60     imagemagick
61     makeWrapper
62   ] ++ lib.optionals stdenv.hostPlatform.isLinux [
63     lsb-release
64     copyDesktopItems
65   ] ++ lib.optionals stdenv.hostPlatform.isDarwin [
66     libicns
67     darwin.sigtool
68   ];
70   buildInputs = [
71     boost
72     glew
73     SDL2
74     SDL2_net
75     libpng
76   ] ++ lib.optionals stdenv.hostPlatform.isLinux [
77     libX11
78     libXrandr
79     libXinerama
80     libXcursor
81     libXi
82     libXext
83     libpulseaudio
84     zenity
85   ] ++ lib.optional stdenv.hostPlatform.isDarwin apple-sdk_11;
87   cmakeFlags = [
88     (lib.cmakeBool "NON_PORTABLE" true)
89     (lib.cmakeFeature "CMAKE_INSTALL_PREFIX" "${placeholder "out"}/lib")
90   ];
92   env.NIX_CFLAGS_COMPILE =
93     lib.optionalString stdenv.hostPlatform.isDarwin "-Wno-int-conversion -Wno-implicit-int";
95   dontAddPrefix = true;
97   # Linking fails without this
98   hardeningDisable = [ "format" ];
100   postBuild = ''
101     cp ${finalAttrs.gamecontrollerdb} ${finalAttrs.gamecontrollerdb.name}
102     pushd ../OTRExporter
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}
104     popd
105   '';
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
112   '';
114   postInstall = lib.optionalString stdenv.hostPlatform.isLinux ''
115     mkdir -p $out/bin
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
129     # Wrapper
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
139     rm -rf $out/lib
140     ln -s $out/Applications/soh.app/Contents/Resources $out/lib
142     # Copy icons
143     cp -r ../build/macosx/soh.icns $out/Applications/soh.app/Contents/Resources/soh.icns
145     # Fix executable
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
156     # Codesign (ad-hoc)
157     codesign -f -s - $out/Applications/soh.app/Contents/Resources/soh-macos
158   '';
160   fixupPhase = lib.optionalString stdenv.hostPlatform.isLinux ''
161     wrapProgram $out/lib/soh.elf --prefix PATH ":" ${lib.makeBinPath [ zenity ]}
162   '';
164   desktopItems = [
165     (makeDesktopItem {
166       name = "soh";
167       icon = "soh";
168       exec = "soh";
169       comment = finalAttrs.meta.description;
170       genericName = "Ship of Harkinian";
171       desktopName = "soh";
172       categories = [ "Game" ];
173     })
174   ];
176   meta = {
177     homepage = "https://github.com/HarbourMasters/Shipwright";
178     description = "A PC port of Ocarina of Time with modern controls, widescreen, high-resolution, and more";
179     mainProgram = "soh";
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
184       mit
185       # Ship of Harkinian itself
186       unfree
187     ];
188   };