2021-04-18 02:13:31 +00:00
|
|
|
{ stdenv, lib, fetchurl, fetchFromGitHub, cmake, python, rustPlatform, SDL2, fltk, rapidjson, gtest, Carbon, Cocoa }:
|
2020-04-24 23:36:52 +00:00
|
|
|
let
|
2021-04-18 02:13:31 +00:00
|
|
|
version = "0.17.0";
|
2020-04-24 23:36:52 +00:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "ja2-stracciatella";
|
|
|
|
repo = "ja2-stracciatella";
|
|
|
|
rev = "v${version}";
|
2021-04-18 02:13:31 +00:00
|
|
|
sha256 = "0m6rvgkba29jy3yq5hs1sn26mwrjl6mamqnv4plrid5fqaivhn6j";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
libstracciatella = rustPlatform.buildRustPackage {
|
|
|
|
pname = "libstracciatella";
|
|
|
|
inherit version;
|
2021-04-18 02:13:31 +00:00
|
|
|
src = "${src}/rust";
|
2021-05-28 09:39:13 +00:00
|
|
|
cargoHash = "sha256-asUt+wUpwwDvSyuNZds6yMC4Ef4D8woMYWamzcJJiy4=";
|
2021-04-18 02:13:31 +00:00
|
|
|
|
|
|
|
preBuild = ''
|
|
|
|
mkdir -p $out/include/stracciatella
|
|
|
|
export HEADER_LOCATION=$out/include/stracciatella/stracciatella.h
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
stringTheoryUrl = "https://github.com/zrax/string_theory/archive/3.1.tar.gz";
|
|
|
|
stringTheory = fetchurl {
|
|
|
|
url = stringTheoryUrl;
|
|
|
|
sha256 = "1flq26kkvx2m1yd38ldcq2k046yqw07jahms8a6614m924bmbv41";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
in
|
|
|
|
stdenv.mkDerivation {
|
|
|
|
pname = "ja2-stracciatella";
|
2021-04-18 02:13:31 +00:00
|
|
|
inherit src version;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-04-18 02:13:31 +00:00
|
|
|
nativeBuildInputs = [ cmake python ];
|
|
|
|
buildInputs = [ SDL2 fltk rapidjson gtest ] ++ lib.optionals stdenv.isDarwin [ Carbon Cocoa ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
patches = [
|
|
|
|
./remove-rust-buildstep.patch
|
|
|
|
];
|
|
|
|
|
|
|
|
preConfigure = ''
|
2021-04-18 02:13:31 +00:00
|
|
|
# Use rust library built with nix
|
|
|
|
substituteInPlace CMakeLists.txt \
|
|
|
|
--replace lib/libstracciatella_c_api.a ${libstracciatella}/lib/libstracciatella_c_api.a \
|
|
|
|
--replace include/stracciatella ${libstracciatella}/include/stracciatella \
|
|
|
|
--replace bin/ja2-resource-pack ${libstracciatella}/bin/ja2-resource-pack
|
|
|
|
|
|
|
|
# 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")
|
|
|
|
'';
|
|
|
|
|
|
|
|
doInstallCheck = true;
|
|
|
|
installCheckPhase = ''
|
|
|
|
HOME=/tmp $out/bin/ja2 -unittests
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
meta = {
|
|
|
|
description = "Jagged Alliance 2, with community fixes";
|
|
|
|
license = "SFI Source Code license agreement";
|
|
|
|
homepage = "https://ja2-stracciatella.github.io/";
|
|
|
|
};
|
|
|
|
}
|