2023-07-15 17:15:38 +00:00
|
|
|
{ stdenv
|
|
|
|
, cmake
|
|
|
|
, lsb-release
|
|
|
|
, ninja
|
|
|
|
, lib
|
|
|
|
, fetchFromGitHub
|
|
|
|
, fetchurl
|
2024-02-07 01:22:34 +00:00
|
|
|
, copyDesktopItems
|
2023-07-15 17:15:38 +00:00
|
|
|
, makeDesktopItem
|
|
|
|
, python3
|
|
|
|
, libX11
|
|
|
|
, libXrandr
|
|
|
|
, libXinerama
|
|
|
|
, libXcursor
|
|
|
|
, libXi
|
|
|
|
, libXext
|
|
|
|
, glew
|
|
|
|
, boost
|
|
|
|
, SDL2
|
|
|
|
, SDL2_net
|
|
|
|
, pkg-config
|
|
|
|
, libpulseaudio
|
|
|
|
, libpng
|
|
|
|
, imagemagick
|
2024-02-07 01:22:34 +00:00
|
|
|
, gnome
|
|
|
|
, makeWrapper
|
2024-06-20 14:57:18 +00:00
|
|
|
, darwin
|
|
|
|
, libicns
|
2023-07-15 17:15:38 +00:00
|
|
|
}:
|
2024-06-20 14:57:18 +00:00
|
|
|
let
|
|
|
|
inherit (darwin.apple_sdk_11_0.frameworks)
|
|
|
|
IOSurface Metal QuartzCore Cocoa AVFoundation;
|
|
|
|
in
|
2024-02-07 01:22:34 +00:00
|
|
|
stdenv.mkDerivation (finalAttrs: {
|
2023-07-15 17:15:38 +00:00
|
|
|
pname = "shipwright";
|
2024-05-15 15:35:15 +00:00
|
|
|
version = "8.0.5";
|
2023-07-15 17:15:38 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "harbourmasters";
|
|
|
|
repo = "shipwright";
|
2024-02-07 01:22:34 +00:00
|
|
|
rev = finalAttrs.version;
|
2024-05-15 15:35:15 +00:00
|
|
|
hash = "sha256-o2VwOF46Iq4pwpumOau3bDXJ/CArx6NWBi00s3E4PnE=";
|
2023-07-15 17:15:38 +00:00
|
|
|
fetchSubmodules = true;
|
|
|
|
};
|
|
|
|
|
2024-06-20 14:57:18 +00:00
|
|
|
patches = [
|
|
|
|
./darwin-fixes.patch
|
|
|
|
];
|
|
|
|
|
2023-07-15 17:15:38 +00:00
|
|
|
# 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";
|
2024-05-15 15:35:15 +00:00
|
|
|
url = "https://raw.githubusercontent.com/gabomdq/SDL_GameControllerDB/b7933e43ca2f8d26d8b668ea8ea52b736221af1e/gamecontrollerdb.txt";
|
|
|
|
hash = "sha256-XIuS9BkWkM9d+SgT1OYTfWtcmzqSUDbMrMLoVnPgidE=";
|
2023-07-15 17:15:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
nativeBuildInputs = [
|
|
|
|
cmake
|
|
|
|
ninja
|
|
|
|
pkg-config
|
|
|
|
python3
|
|
|
|
imagemagick
|
2024-02-07 01:22:34 +00:00
|
|
|
makeWrapper
|
2024-06-20 14:57:18 +00:00
|
|
|
] ++ lib.optionals stdenv.isLinux [
|
|
|
|
lsb-release
|
|
|
|
copyDesktopItems
|
|
|
|
] ++ lib.optionals stdenv.isDarwin [
|
|
|
|
libicns
|
|
|
|
darwin.sigtool
|
2023-07-15 17:15:38 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
buildInputs = [
|
|
|
|
boost
|
2024-06-20 14:57:18 +00:00
|
|
|
glew
|
|
|
|
SDL2
|
|
|
|
SDL2_net
|
|
|
|
libpng
|
|
|
|
] ++ lib.optionals stdenv.isLinux [
|
2023-07-15 17:15:38 +00:00
|
|
|
libX11
|
|
|
|
libXrandr
|
|
|
|
libXinerama
|
|
|
|
libXcursor
|
|
|
|
libXi
|
|
|
|
libXext
|
|
|
|
libpulseaudio
|
2024-02-07 01:22:34 +00:00
|
|
|
gnome.zenity
|
2024-06-20 14:57:18 +00:00
|
|
|
] ++ lib.optionals stdenv.isDarwin [
|
|
|
|
IOSurface
|
|
|
|
Metal
|
|
|
|
QuartzCore
|
|
|
|
Cocoa
|
|
|
|
AVFoundation
|
|
|
|
darwin.apple_sdk_11_0.libs.simd
|
2023-07-15 17:15:38 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
cmakeFlags = [
|
|
|
|
"-DCMAKE_INSTALL_PREFIX=${placeholder "out"}/lib"
|
2024-02-07 01:22:34 +00:00
|
|
|
(lib.cmakeBool "NON_PORTABLE" true)
|
2023-07-15 17:15:38 +00:00
|
|
|
];
|
|
|
|
|
2024-06-20 14:57:18 +00:00
|
|
|
env.NIX_CFLAGS_COMPILE =
|
|
|
|
lib.optionalString stdenv.isDarwin "-Wno-int-conversion -Wno-implicit-int";
|
|
|
|
|
2023-07-15 17:15:38 +00:00
|
|
|
dontAddPrefix = true;
|
|
|
|
|
|
|
|
# Linking fails without this
|
|
|
|
hardeningDisable = [ "format" ];
|
|
|
|
|
|
|
|
postBuild = ''
|
2024-02-07 01:22:34 +00:00
|
|
|
cp ${finalAttrs.gamecontrollerdb} ${finalAttrs.gamecontrollerdb.name}
|
2023-07-15 17:15:38 +00:00
|
|
|
pushd ../OTRExporter
|
2024-02-07 01:22:34 +00:00
|
|
|
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}
|
2023-07-15 17:15:38 +00:00
|
|
|
popd
|
|
|
|
'';
|
|
|
|
|
2024-06-20 14:57:18 +00:00
|
|
|
preInstall = lib.optionalString stdenv.isLinux ''
|
2023-07-15 17:15:38 +00:00
|
|
|
# Cmake likes it here for its install paths
|
|
|
|
cp ../OTRExporter/soh.otr ..
|
2024-06-20 14:57:18 +00:00
|
|
|
'' + lib.optionalString stdenv.isDarwin ''
|
|
|
|
cp ../OTRExporter/soh.otr soh/soh.otr
|
2023-07-15 17:15:38 +00:00
|
|
|
'';
|
|
|
|
|
2024-06-20 14:57:18 +00:00
|
|
|
postInstall = lib.optionalString stdenv.isLinux ''
|
2023-07-15 17:15:38 +00:00
|
|
|
mkdir -p $out/bin
|
|
|
|
ln -s $out/lib/soh.elf $out/bin/soh
|
2024-02-07 01:22:34 +00:00
|
|
|
install -Dm644 ../soh/macosx/sohIcon.png $out/share/pixmaps/soh.png
|
2024-06-20 14:57:18 +00:00
|
|
|
'' + lib.optionalString stdenv.isDarwin ''
|
|
|
|
# Recreate the macOS bundle (without using cpack)
|
|
|
|
# We mirror the structure of the bundle distributed by the project
|
|
|
|
|
|
|
|
mkdir -p $out/Applications/soh.app/Contents
|
|
|
|
cp $src/soh/macosx/Info.plist.in $out/Applications/soh.app/Contents/Info.plist
|
|
|
|
substituteInPlace $out/Applications/soh.app/Contents/Info.plist \
|
|
|
|
--replace-fail "@CMAKE_PROJECT_VERSION@" "${finalAttrs.version}"
|
|
|
|
|
|
|
|
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.
|
|
|
|
mv $out/Resources $out/Applications/soh.app/Contents/Resources
|
|
|
|
mv $out/lib/** $out/Applications/soh.app/Contents/Resources
|
|
|
|
rm -rf $out/lib
|
|
|
|
ln -s $out/Applications/soh.app/Contents/Resources $out/lib
|
|
|
|
|
|
|
|
# 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
|
2024-02-07 01:22:34 +00:00
|
|
|
'';
|
|
|
|
|
2024-06-20 14:57:18 +00:00
|
|
|
fixupPhase = lib.optionalString stdenv.isLinux ''
|
2024-02-07 01:22:34 +00:00
|
|
|
wrapProgram $out/lib/soh.elf --prefix PATH ":" ${lib.makeBinPath [ gnome.zenity ]}
|
2023-07-15 17:15:38 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
desktopItems = [
|
|
|
|
(makeDesktopItem {
|
|
|
|
name = "soh";
|
|
|
|
icon = "soh";
|
|
|
|
exec = "soh";
|
2024-02-07 01:22:34 +00:00
|
|
|
comment = finalAttrs.meta.description;
|
2023-07-15 17:15:38 +00:00
|
|
|
genericName = "Ship of Harkinian";
|
|
|
|
desktopName = "soh";
|
|
|
|
categories = [ "Game" ];
|
|
|
|
})
|
|
|
|
];
|
|
|
|
|
2024-02-07 01:22:34 +00:00
|
|
|
meta = {
|
2023-07-15 17:15:38 +00:00
|
|
|
homepage = "https://github.com/HarbourMasters/Shipwright";
|
|
|
|
description = "A PC port of Ocarina of Time with modern controls, widescreen, high-resolution, and more";
|
|
|
|
mainProgram = "soh";
|
2024-06-20 14:57:18 +00:00
|
|
|
platforms = [ "x86_64-linux" ] ++ lib.platforms.darwin;
|
|
|
|
maintainers = with lib.maintainers; [ ivar j0lol matteopacini ];
|
2024-02-07 01:22:34 +00:00
|
|
|
license = with lib.licenses; [
|
2023-07-15 17:15:38 +00:00
|
|
|
# OTRExporter, OTRGui, ZAPDTR, libultraship
|
|
|
|
mit
|
|
|
|
# Ship of Harkinian itself
|
|
|
|
unfree
|
|
|
|
];
|
|
|
|
};
|
2024-02-07 01:22:34 +00:00
|
|
|
})
|