Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9513882870 | ||
|
|
71a6843b37 | ||
|
|
7d9d1ca80e |
61
nix/configuration/flakes/starship-game/flake.lock
generated
Normal file
61
nix/configuration/flakes/starship-game/flake.lock
generated
Normal file
@@ -0,0 +1,61 @@
|
||||
{
|
||||
"nodes": {
|
||||
"flake-utils": {
|
||||
"inputs": {
|
||||
"systems": "systems"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1731533236,
|
||||
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1735141468,
|
||||
"narHash": "sha256-VIAjBr1qGcEbmhLwQJD6TABppPMggzOvqFsqkDoMsAY=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "4005c3ff7505313cbc21081776ad0ce5dfd7a3ce",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixos-24.11",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": "nixpkgs"
|
||||
}
|
||||
},
|
||||
"systems": {
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
||||
34
nix/configuration/flakes/starship-game/flake.nix
Normal file
34
nix/configuration/flakes/starship-game/flake.nix
Normal file
@@ -0,0 +1,34 @@
|
||||
{
|
||||
description = "A slightly better history for zsh";
|
||||
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11";
|
||||
inputs.flake-utils.url = "github:numtide/flake-utils";
|
||||
|
||||
outputs =
|
||||
{
|
||||
self,
|
||||
nixpkgs,
|
||||
flake-utils,
|
||||
...
|
||||
}:
|
||||
let
|
||||
out =
|
||||
system:
|
||||
let
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
# Maybe pkgs = import nixpkgs { inherit system; }; ?
|
||||
appliedOverlay = self.overlays.default pkgs pkgs;
|
||||
in
|
||||
{
|
||||
packages = rec {
|
||||
default = starship-game;
|
||||
starship-game = appliedOverlay.starship-game;
|
||||
};
|
||||
};
|
||||
in
|
||||
flake-utils.lib.eachDefaultSystem out
|
||||
// {
|
||||
overlays.default = final: prev: {
|
||||
starship-game = final.callPackage ./package.nix { };
|
||||
};
|
||||
};
|
||||
}
|
||||
261
nix/configuration/flakes/starship-game/package.nix
Normal file
261
nix/configuration/flakes/starship-game/package.nix
Normal file
@@ -0,0 +1,261 @@
|
||||
{
|
||||
lib,
|
||||
stdenv,
|
||||
SDL2,
|
||||
cmake,
|
||||
copyDesktopItems,
|
||||
fetchFromGitHub,
|
||||
fetchpatch,
|
||||
fetchurl,
|
||||
imagemagick,
|
||||
imgui,
|
||||
libpng,
|
||||
libpulseaudio,
|
||||
libzip,
|
||||
lsb-release,
|
||||
makeDesktopItem,
|
||||
makeWrapper,
|
||||
ninja,
|
||||
nlohmann_json,
|
||||
pkg-config,
|
||||
python3,
|
||||
spdlog,
|
||||
stormlib,
|
||||
tinyxml-2,
|
||||
writeTextFile,
|
||||
zenity,
|
||||
}:
|
||||
|
||||
let
|
||||
|
||||
# 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=";
|
||||
};
|
||||
|
||||
# 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=";
|
||||
};
|
||||
};
|
||||
|
||||
libgfxd = fetchFromGitHub {
|
||||
owner = "glankk";
|
||||
repo = "libgfxd";
|
||||
rev = "96fd3b849f38b3a7c7b7f3ff03c5921d328e6cdf";
|
||||
hash = "sha256-dedZuV0BxU6goT+rPvrofYqTz9pTA/f6eQcsvpDWdvQ=";
|
||||
};
|
||||
|
||||
yaml_cpp = fetchFromGitHub {
|
||||
owner = "jbeder";
|
||||
repo = "yaml-cpp";
|
||||
rev = "f7320141120f720aecc4c32be25586e7da9eb978";
|
||||
hash = "sha256-J87oS6Az1/vNdyXu3L7KmUGWzU0IAkGrGMUUha+xDXI=";
|
||||
};
|
||||
|
||||
# spdlog = fetchFromGitHub {
|
||||
# owner = "gabime";
|
||||
# repo = "spdlog";
|
||||
# rev = "7e635fca68d014934b4af8a1cf874f63989352b7";
|
||||
# hash = "sha256-cxTaOuLXHRU8xMz9gluYz0a93O0ez2xOxbloyc1m1ns=";
|
||||
# };
|
||||
|
||||
# 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=";
|
||||
# };
|
||||
|
||||
# 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=";
|
||||
};
|
||||
nativeBuildInputs = prev.nativeBuildInputs ++ [ 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 = "starship-game";
|
||||
version = "v1.0.0";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "HarbourMasters";
|
||||
repo = "starship";
|
||||
# rev = "5e5e49da93e066f51c3010ba38f09331d866f2db";
|
||||
tag = finalAttrs.version;
|
||||
hash = "sha256-kaLLlLuonqE2DJcRlWR4tCEBNjwIYFlzeDLcYsvMO7I=";
|
||||
fetchSubmodules = true;
|
||||
};
|
||||
|
||||
# patches = [
|
||||
# # remove fetching stb as we will patch our own
|
||||
# ./0001-deps.patch
|
||||
# ];
|
||||
|
||||
nativeBuildInputs = [
|
||||
cmake
|
||||
copyDesktopItems
|
||||
imagemagick
|
||||
lsb-release
|
||||
makeWrapper
|
||||
ninja
|
||||
pkg-config
|
||||
python3
|
||||
];
|
||||
|
||||
buildInputs = [
|
||||
SDL2
|
||||
imgui'
|
||||
libpng
|
||||
libpulseaudio
|
||||
libzip
|
||||
nlohmann_json
|
||||
spdlog
|
||||
stormlib'
|
||||
tinyxml-2
|
||||
zenity
|
||||
];
|
||||
|
||||
cmakeFlags = [
|
||||
(lib.cmakeBool "NON_PORTABLE" true)
|
||||
(lib.cmakeFeature "CMAKE_INSTALL_PREFIX" "${placeholder "out"}/starship-game")
|
||||
(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}")
|
||||
];
|
||||
|
||||
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"
|
||||
# '';
|
||||
|
||||
# (cd tools/Torch && cmake -H. -Bbuild-cmake -GNinja \
|
||||
# -DFETCHCONTENT_SOURCE_DIR_LIBGFXD=${libgfxd} \
|
||||
# -DFETCHCONTENT_SOURCE_DIR_YAML-CPP=${finalAttrs.yaml_cpp_src} \
|
||||
# -DFETCHCONTENT_SOURCE_DIR_SPDLOG=${finalAttrs.spdlog_src}
|
||||
# )
|
||||
|
||||
configurePhase = ''
|
||||
cmake -H. -Bbuild-cmake -GNinja \
|
||||
-DFETCHCONTENT_SOURCE_DIR_IMGUI=${imgui'.src} \
|
||||
-DFETCHCONTENT_SOURCE_DIR_STORMLIB=${stormlib'} \
|
||||
-DFETCHCONTENT_SOURCE_DIR_THREADPOOL=${thread_pool}
|
||||
|
||||
(cd tools/Torch && cmake -H. -Bbuild-cmake -GNinja \
|
||||
-DFETCHCONTENT_SOURCE_DIR_LIBGFXD=${libgfxd} \
|
||||
-DFETCHCONTENT_SOURCE_DIR_YAML-CPP=${yaml_cpp} \
|
||||
-DFETCHCONTENT_SOURCE_DIR_SPDLOG=${spdlog}
|
||||
)
|
||||
|
||||
(cd libultraship && cmake -H. -Bbuild-cmake -GNinja \
|
||||
-DFETCHCONTENT_SOURCE_DIR_LIBGFXD=${libgfxd} \
|
||||
-DFETCHCONTENT_SOURCE_DIR_IMGUI=${imgui'.src} \
|
||||
-DFETCHCONTENT_SOURCE_DIR_STORMLIB=${stormlib'} \
|
||||
-DFETCHCONTENT_SOURCE_DIR_THREADPOOL=${thread_pool}
|
||||
)
|
||||
|
||||
'';
|
||||
|
||||
buildPhase = ''
|
||||
cmake --build build-cmake
|
||||
'';
|
||||
|
||||
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
|
||||
'';
|
||||
|
||||
postFixup = ''
|
||||
wrapProgram $out/2s2h/2s2h.elf --prefix PATH ":" ${lib.makeBinPath [ zenity ]}
|
||||
'';
|
||||
|
||||
desktopItems = [
|
||||
(makeDesktopItem {
|
||||
name = "starship";
|
||||
icon = "starship";
|
||||
exec = "starship";
|
||||
comment = finalAttrs.meta.description;
|
||||
genericName = "Starship";
|
||||
desktopName = "starship";
|
||||
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 = "starship";
|
||||
platforms = [ "x86_64-linux" ];
|
||||
maintainers = with lib.maintainers; [ ];
|
||||
license = with lib.licenses; [
|
||||
# # OTRExporter, OTRGui, ZAPDTR, libultraship
|
||||
# mit
|
||||
# # 2 Ship 2 Harkinian
|
||||
# cc0
|
||||
# # Reverse engineering
|
||||
# unfree
|
||||
];
|
||||
};
|
||||
})
|
||||
Reference in New Issue
Block a user