Skip to content

Commit

Permalink
ja2-stracciatella: clean up and modernize
Browse files Browse the repository at this point in the history
  • Loading branch information
TomaSajt authored and alyssais committed Jan 31, 2025
1 parent 882709b commit 6f5506c
Showing 1 changed file with 20 additions and 13 deletions.
33 changes: 20 additions & 13 deletions pkgs/by-name/ja/ja2-stracciatella/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@
}:

let
stringTheoryUrl = "https://github.com/zrax/string_theory/archive/3.1.tar.gz";
stringTheory = fetchurl {
url = stringTheoryUrl;
sha256 = "1flq26kkvx2m1yd38ldcq2k046yqw07jahms8a6614m924bmbv41";
url = "https://github.com/zrax/string_theory/archive/3.1.tar.gz";
hash = "sha256-gexVFxGpkmCMQrpCJQ/g2BsCpsCsUTSaD1X0PacRmLo=";
};
in
stdenv.mkDerivation rec {
Expand All @@ -28,15 +27,23 @@ stdenv.mkDerivation rec {
src = fetchFromGitHub {
owner = "ja2-stracciatella";
repo = "ja2-stracciatella";
rev = "v${version}";
sha256 = "0m6rvgkba29jy3yq5hs1sn26mwrjl6mamqnv4plrid5fqaivhn6j";
tag = "v${version}";
hash = "sha256-0li4o8KutJjpJdviqqqhMvNqhNVBw4L98DIJtebb2VQ=";
};

patches = [
# Note: this patch is only relevant for darwin
./dont-use-vendored-sdl2.patch
];

postPatch = ''
# Patch dependencies that are usually loaded by url
substituteInPlace dependencies/lib-string_theory/builder/CMakeLists.txt.in \
--replace-fail ${stringTheory.url} file://${stringTheory}
'';

strictDeps = true;

nativeBuildInputs = [
cmake
python3
Expand Down Expand Up @@ -64,26 +71,26 @@ stdenv.mkDerivation rec {
hash = "sha256-zkctR16QIjCTiDmrhFqPPOThbPwsm0T0nlnCekkXNN8=";
};

preConfigure = ''
# Patch dependencies that are usually loaded by url
substituteInPlace dependencies/lib-string_theory/builder/CMakeLists.txt.in \
--replace ${stringTheoryUrl} file://${stringTheory}
cmakeFlagsArray+=("-DLOCAL_RAPIDJSON_LIB=OFF" "-DLOCAL_GTEST_LIB=OFF" "-DEXTRA_DATA_DIR=$out/share/ja2")
'';
cmakeFlags = [
(lib.cmakeBool "LOCAL_RAPIDJSON_LIB" false)
(lib.cmakeBool "LOCAL_GTEST_LIB" false)
(lib.cmakeFeature "EXTRA_DATA_DIR" "${placeholder "out"}/share/ja2")
];

# error: 'uint64_t' does not name a type
# gcc13 and above don't automatically include cstdint
env.CXXFLAGS = "-include cstdint";

doInstallCheck = true;

installCheckPhase = ''
HOME=/tmp $out/bin/ja2 -unittests
HOME=$(mktemp -d) $out/bin/ja2 -unittests
'';

meta = {
description = "Jagged Alliance 2, with community fixes";
license = "SFI Source Code license agreement";
homepage = "https://ja2-stracciatella.github.io/";
maintainers = [ ];
};
}

0 comments on commit 6f5506c

Please sign in to comment.