2021-04-16 08:46:38 +01:00
|
|
|
{ stdenv, lib, fetchurl, fetchFromGitHub, cmake, python, rustPlatform, SDL2, fltk, rapidjson, gtest, Carbon, Cocoa }:
|
2018-07-15 11:11:02 +01:00
|
|
|
let
|
2021-04-16 08:46:38 +01:00
|
|
|
version = "0.17.0";
|
2017-02-15 03:00:28 +00:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "ja2-stracciatella";
|
|
|
|
repo = "ja2-stracciatella";
|
|
|
|
rev = "v${version}";
|
2021-04-16 08:46:38 +01:00
|
|
|
sha256 = "0m6rvgkba29jy3yq5hs1sn26mwrjl6mamqnv4plrid5fqaivhn6j";
|
2018-07-15 11:11:02 +01:00
|
|
|
};
|
2020-03-09 04:15:13 +00:00
|
|
|
libstracciatella = rustPlatform.buildRustPackage {
|
|
|
|
pname = "libstracciatella";
|
2018-07-15 11:11:02 +01:00
|
|
|
inherit version;
|
2021-04-16 08:46:38 +01:00
|
|
|
src = "${src}/rust";
|
|
|
|
cargoSha256 = "0blb971cv9k6c460mwq3zq8vih687bdnb39b9gph1hr90pxjviba";
|
|
|
|
|
|
|
|
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";
|
2017-02-15 03:00:28 +00:00
|
|
|
};
|
2018-07-15 11:11:02 +01:00
|
|
|
in
|
2019-08-13 22:52:01 +01:00
|
|
|
stdenv.mkDerivation {
|
2019-08-15 13:41:18 +01:00
|
|
|
pname = "ja2-stracciatella";
|
2021-04-16 08:46:38 +01:00
|
|
|
inherit src version;
|
2018-07-15 11:11:02 +01:00
|
|
|
|
2021-04-16 08:46:38 +01:00
|
|
|
nativeBuildInputs = [ cmake python ];
|
|
|
|
buildInputs = [ SDL2 fltk rapidjson gtest ] ++ lib.optionals stdenv.isDarwin [ Carbon Cocoa ];
|
2018-07-15 11:11:02 +01:00
|
|
|
|
|
|
|
patches = [
|
|
|
|
./remove-rust-buildstep.patch
|
|
|
|
];
|
2020-03-09 04:15:13 +00:00
|
|
|
|
2018-07-15 11:11:02 +01:00
|
|
|
preConfigure = ''
|
2021-04-16 08:46:38 +01: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
|
2018-07-15 11:11:02 +01:00
|
|
|
'';
|
|
|
|
|
2017-02-15 03:00:28 +00:00
|
|
|
meta = {
|
|
|
|
description = "Jagged Alliance 2, with community fixes";
|
|
|
|
license = "SFI Source Code license agreement";
|
2020-03-09 04:15:13 +00:00
|
|
|
homepage = "https://ja2-stracciatella.github.io/";
|
2017-02-15 03:00:28 +00:00
|
|
|
};
|
|
|
|
}
|