31 # This would get fetched at build time otherwise, see:
32 # https://github.com/HarbourMasters/2ship2harkinian/blob/1.0.2/mm/CMakeLists.txt#L708
33 gamecontrollerdb = fetchurl {
34 name = "gamecontrollerdb.txt";
35 url = "https://raw.githubusercontent.com/gabomdq/SDL_GameControllerDB/b1759cf84028aab89caa1c395e198c340b8dfd89/gamecontrollerdb.txt";
36 hash = "sha256-7C5EkqBIhLGNJuhi3832y0ffW5Ep7iuTYXb1bL5h2Js=";
39 # 2ship needs a specific imgui version
40 imgui' = imgui.overrideAttrs rec {
42 src = fetchFromGitHub {
45 rev = "v${version}-docking";
46 hash = "sha256-Y8lZb1cLJF48sbuxQ3vXq6GLru/WThR78pq7LlORIzc=";
50 libgfxd = fetchFromGitHub {
53 rev = "008f73dca8ebc9151b205959b17773a19c5bd0da";
54 hash = "sha256-AmHAa3/cQdh7KAMFOtz5TQpcM6FqO9SppmDpKPTjTt8=";
57 stb_impl = writeTextFile {
60 #define STB_IMAGE_IMPLEMENTATION
61 #include "stb_image.h"
67 url = "https://raw.githubusercontent.com/nothings/stb/0bc88af4de5fb022db643c2d8e549a0927749354/stb_image.h";
68 hash = "sha256-xUsVponmofMsdeLsI6+kQuPg436JS3PBl00IZ5sg3Vw=";
71 # Apply 2ship's patch for stormlib
72 stormlib' = stormlib.overrideAttrs (prev: rec {
74 src = fetchFromGitHub {
75 owner = "ladislav-zezula";
78 hash = "sha256-HTi2FKzKCbRaP13XERUmHkJgw8IfKaRJvsK3+YxFFdc=";
80 nativeBuildInputs = prev.nativeBuildInputs ++ [ pkg-config ];
81 patches = (prev.patches or [ ]) ++ [
83 name = "stormlib-optimizations.patch";
84 url = "https://github.com/briaguya-ai/StormLib/commit/ff338b230544f8b2bb68d2fbe075175ed2fd758c.patch";
85 hash = "sha256-Jbnsu5E6PkBifcx/yULMVC//ab7tszYgktS09Azs5+4=";
90 thread_pool = fetchFromGitHub {
94 hash = "sha256-zhRFEmPYNFLqQCfvdAaG5VBNle9Qm8FepIIIrT9sh88=";
98 stdenv.mkDerivation (finalAttrs: {
99 pname = "2ship2harkinian";
102 src = fetchFromGitHub {
103 owner = "HarbourMasters";
104 repo = "2ship2harkinian";
105 rev = "refs/tags/${finalAttrs.version}";
106 hash = "sha256-1iSFzroKxwFpsIGNMetSlQKTKRWCy7QtgCTepFdSeY8=";
107 fetchSubmodules = true;
111 # remove fetching stb as we will patch our own
115 nativeBuildInputs = [
140 (lib.cmakeBool "NON_PORTABLE" true)
141 (lib.cmakeFeature "CMAKE_INSTALL_PREFIX" "${placeholder "out"}/2s2h")
142 (lib.cmakeFeature "FETCHCONTENT_SOURCE_DIR_IMGUI" "${imgui'.src}")
143 (lib.cmakeFeature "FETCHCONTENT_SOURCE_DIR_LIBGFXD" "${libgfxd}")
144 (lib.cmakeFeature "FETCHCONTENT_SOURCE_DIR_STORMLIB" "${stormlib'}")
145 (lib.cmakeFeature "FETCHCONTENT_SOURCE_DIR_THREADPOOL" "${thread_pool}")
148 dontAddPrefix = true;
150 # Linking fails without this
151 hardeningDisable = [ "format" ];
153 # Pie needs to be enabled or else it segfaults
154 hardeningEnable = [ "pie" ];
159 cp ${stb'} ./stb/${stb'.name}
160 cp ${stb_impl} ./stb/${stb_impl.name}
162 substituteInPlace libultraship/cmake/dependencies/common.cmake \
163 --replace-fail "\''${STB_DIR}" "/build/source/stb"
167 cp ${gamecontrollerdb} ${gamecontrollerdb.name}
169 python3 ./extract_assets.py -z ../build/ZAPD/ZAPD.out --norom --xml-root ../mm/assets/xml --custom-assets-path ../mm/assets/custom --custom-otr-file 2ship.o2r --port-ver ${finalAttrs.version}
174 # Cmake likes it here for its install paths
175 cp ../OTRExporter/2ship.o2r mm/
180 ln -s $out/2s2h/2s2h.elf $out/bin/2s2h
181 install -Dm644 ../mm/linux/2s2hIcon.png $out/share/pixmaps/2s2h.png
185 wrapProgram $out/2s2h/2s2h.elf --prefix PATH ":" ${lib.makeBinPath [ zenity ]}
193 comment = finalAttrs.meta.description;
194 genericName = "2 Ship 2 Harkinian";
195 desktopName = "2s2h";
196 categories = [ "Game" ];
201 homepage = "https://github.com/HarbourMasters/2ship2harkinian";
202 description = "A PC port of Majora's Mask with modern controls, widescreen, high-resolution, and more";
203 mainProgram = "2s2h";
204 platforms = [ "x86_64-linux" ];
205 maintainers = with lib.maintainers; [ qubitnano ];
206 license = with lib.licenses; [
207 # OTRExporter, OTRGui, ZAPDTR, libultraship
211 # Reverse engineering