1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-11-18 03:30:45 +00:00
nixpkgs/pkgs/by-name/_2/_2ship2harkinian/package.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

217 lines
5.4 KiB
Nix
Raw Normal View History

2024-06-01 03:01:06 +01:00
{
2024-07-11 23:38:37 +01:00
lib,
2024-06-01 03:01:06 +01:00
stdenv,
2024-07-11 23:38:37 +01:00
SDL2,
2024-06-01 03:01:06 +01:00
cmake,
2024-07-11 23:38:37 +01:00
copyDesktopItems,
2024-06-01 03:01:06 +01:00
fetchFromGitHub,
2024-07-11 23:38:37 +01:00
fetchpatch,
2024-06-01 03:01:06 +01:00
fetchurl,
imagemagick,
imgui,
2024-07-11 23:38:37 +01:00
libpng,
libpulseaudio,
2024-06-01 03:01:06 +01:00
libzip,
2024-07-11 23:38:37 +01:00
lsb-release,
makeDesktopItem,
makeWrapper,
ninja,
2024-06-01 03:01:06 +01:00
nlohmann_json,
2024-07-11 23:38:37 +01:00
pkg-config,
python3,
2024-06-01 03:01:06 +01:00
spdlog,
2024-07-11 23:38:37 +01:00
stormlib,
tinyxml-2,
2024-06-01 03:01:06 +01:00
writeTextFile,
2024-07-11 23:38:37 +01:00
zenity,
2024-06-01 03:01:06 +01:00
}:
let
2024-07-11 23:38:37 +01:00
# This would get fetched at build time otherwise, see:
# https://github.com/HarbourMasters/2ship2harkinian/blob/1.0.2/mm/CMakeLists.txt#L708
gamecontrollerdb = fetchurl {
name = "gamecontrollerdb.txt";
url = "https://raw.githubusercontent.com/gabomdq/SDL_GameControllerDB/b1759cf84028aab89caa1c395e198c340b8dfd89/gamecontrollerdb.txt";
hash = "sha256-7C5EkqBIhLGNJuhi3832y0ffW5Ep7iuTYXb1bL5h2Js=";
};
2024-06-01 03:01:06 +01:00
# 2ship needs a specific imgui version
imgui' = imgui.overrideAttrs rec {
version = "1.90.6";
src = fetchFromGitHub {
owner = "ocornut";
repo = "imgui";
rev = "v${version}-docking";
hash = "sha256-Y8lZb1cLJF48sbuxQ3vXq6GLru/WThR78pq7LlORIzc=";
};
};
2024-07-11 23:38:37 +01:00
libgfxd = fetchFromGitHub {
owner = "glankk";
repo = "libgfxd";
rev = "008f73dca8ebc9151b205959b17773a19c5bd0da";
hash = "sha256-AmHAa3/cQdh7KAMFOtz5TQpcM6FqO9SppmDpKPTjTt8=";
};
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=";
};
2024-06-01 03:01:06 +01:00
# Apply 2ship's patch for stormlib
stormlib' = stormlib.overrideAttrs (prev: rec {
version = "9.25";
src = fetchFromGitHub {
owner = "ladislav-zezula";
repo = "StormLib";
rev = "v${version}";
hash = "sha256-HTi2FKzKCbRaP13XERUmHkJgw8IfKaRJvsK3+YxFFdc=";
};
buildInputs = prev.buildInputs ++ [ pkg-config ];
patches = (prev.patches or [ ]) ++ [
(fetchpatch {
name = "stormlib-optimizations.patch";
url = "https://github.com/briaguya-ai/StormLib/commit/ff338b230544f8b2bb68d2fbe075175ed2fd758c.patch";
hash = "sha256-Jbnsu5E6PkBifcx/yULMVC//ab7tszYgktS09Azs5+4=";
})
];
});
thread_pool = fetchFromGitHub {
owner = "bshoshany";
repo = "thread-pool";
rev = "v4.1.0";
hash = "sha256-zhRFEmPYNFLqQCfvdAaG5VBNle9Qm8FepIIIrT9sh88=";
};
in
stdenv.mkDerivation (finalAttrs: {
pname = "2ship2harkinian";
2024-07-11 23:39:07 +01:00
version = "1.0.2";
2024-06-01 03:01:06 +01:00
src = fetchFromGitHub {
owner = "HarbourMasters";
repo = "2ship2harkinian";
2024-07-11 23:39:07 +01:00
rev = "refs/tags/${finalAttrs.version}";
hash = "sha256-1iSFzroKxwFpsIGNMetSlQKTKRWCy7QtgCTepFdSeY8=";
2024-06-01 03:01:06 +01:00
fetchSubmodules = true;
};
2024-07-11 23:38:37 +01:00
patches = [
# remove fetching stb as we will patch our own
./0001-deps.patch
];
2024-06-01 03:01:06 +01:00
nativeBuildInputs = [
cmake
2024-07-11 23:38:37 +01:00
copyDesktopItems
imagemagick
lsb-release
makeWrapper
2024-06-01 03:01:06 +01:00
ninja
pkg-config
python3
];
buildInputs = [
SDL2
imgui'
2024-07-11 23:38:37 +01:00
libpng
libpulseaudio
2024-06-01 03:01:06 +01:00
libzip
nlohmann_json
spdlog
2024-07-11 23:38:37 +01:00
stormlib'
tinyxml-2
zenity
2024-06-01 03:01:06 +01:00
];
cmakeFlags = [
(lib.cmakeBool "NON_PORTABLE" true)
2024-07-11 23:38:37 +01:00
(lib.cmakeFeature "CMAKE_BUILD_TYPE" "Release")
(lib.cmakeFeature "CMAKE_INSTALL_PREFIX" "${placeholder "out"}/2s2h")
(lib.cmakeFeature "FETCHCONTENT_SOURCE_DIR_IMGUI" "${imgui'.src}")
(lib.cmakeFeature "FETCHCONTENT_SOURCE_DIR_LIBGFXD" "${libgfxd}")
(lib.cmakeFeature "FETCHCONTENT_SOURCE_DIR_STORMLIB" "${stormlib'}")
(lib.cmakeFeature "FETCHCONTENT_SOURCE_DIR_THREADPOOL" "${thread_pool}")
2024-06-01 03:01:06 +01:00
];
dontAddPrefix = true;
# Linking fails without this
hardeningDisable = [ "format" ];
# Pie needs to be enabled or else it segfaults
hardeningEnable = [ "pie" ];
preConfigure = ''
# mirror 2ship's stb
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"
'';
postBuild = ''
cp ${gamecontrollerdb} ${gamecontrollerdb.name}
pushd ../OTRExporter
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}
popd
'';
preInstall = ''
# Cmake likes it here for its install paths
cp ../OTRExporter/2ship.o2r mm/
'';
postInstall = ''
mkdir -p $out/bin
ln -s $out/2s2h/2s2h.elf $out/bin/2s2h
install -Dm644 ../mm/linux/2s2hIcon.png $out/share/pixmaps/2s2h.png
'';
2024-07-11 23:38:37 +01:00
postFixup = ''
wrapProgram $out/2s2h/2s2h.elf --prefix PATH ":" ${lib.makeBinPath [ zenity ]}
2024-06-01 03:01:06 +01:00
'';
desktopItems = [
(makeDesktopItem {
name = "2s2h";
icon = "2s2h";
exec = "2s2h";
comment = finalAttrs.meta.description;
genericName = "2 Ship 2 Harkinian";
desktopName = "2s2h";
categories = [ "Game" ];
})
];
meta = {
homepage = "https://github.com/HarbourMasters/2ship2harkinian";
description = "A PC port of Majora's Mask with modern controls, widescreen, high-resolution, and more";
mainProgram = "2s2h";
platforms = [ "x86_64-linux" ];
maintainers = with lib.maintainers; [ qubitnano ];
license = with lib.licenses; [
# OTRExporter, OTRGui, ZAPDTR, libultraship
mit
# 2 Ship 2 Harkinian
cc0
# Reverse engineering
unfree
];
};
})