1 { stdenv, lib, fetchurl, fetchFromGitHub, cmake, python3, rustPlatform, SDL2, fltk, rapidjson, gtest, Carbon, Cocoa }:
4 src = fetchFromGitHub {
5 owner = "ja2-stracciatella";
6 repo = "ja2-stracciatella";
8 sha256 = "0m6rvgkba29jy3yq5hs1sn26mwrjl6mamqnv4plrid5fqaivhn6j";
10 libstracciatella = rustPlatform.buildRustPackage {
11 pname = "libstracciatella";
14 cargoHash = "sha256-asUt+wUpwwDvSyuNZds6yMC4Ef4D8woMYWamzcJJiy4=";
17 mkdir -p $out/include/stracciatella
18 export HEADER_LOCATION=$out/include/stracciatella/stracciatella.h
21 stringTheoryUrl = "https://github.com/zrax/string_theory/archive/3.1.tar.gz";
22 stringTheory = fetchurl {
23 url = stringTheoryUrl;
24 sha256 = "1flq26kkvx2m1yd38ldcq2k046yqw07jahms8a6614m924bmbv41";
28 pname = "ja2-stracciatella";
31 nativeBuildInputs = [ cmake python3 ];
32 buildInputs = [ SDL2 fltk rapidjson gtest ] ++ lib.optionals stdenv.isDarwin [ Carbon Cocoa ];
35 ./remove-rust-buildstep.patch
39 # Use rust library built with nix
40 substituteInPlace CMakeLists.txt \
41 --replace lib/libstracciatella_c_api.a ${libstracciatella}/lib/libstracciatella_c_api.a \
42 --replace include/stracciatella ${libstracciatella}/include/stracciatella \
43 --replace bin/ja2-resource-pack ${libstracciatella}/bin/ja2-resource-pack
45 # Patch dependencies that are usually loaded by url
46 substituteInPlace dependencies/lib-string_theory/builder/CMakeLists.txt.in \
47 --replace ${stringTheoryUrl} file://${stringTheory}
49 cmakeFlagsArray+=("-DLOCAL_RAPIDJSON_LIB=OFF" "-DLOCAL_GTEST_LIB=OFF" "-DEXTRA_DATA_DIR=$out/share/ja2")
52 doInstallCheck = true;
53 installCheckPhase = ''
54 HOME=/tmp $out/bin/ja2 -unittests
58 description = "Jagged Alliance 2, with community fixes";
59 license = "SFI Source Code license agreement";
60 homepage = "https://ja2-stracciatella.github.io/";