diff options
Diffstat (limited to 'pkgs/games/ja2-stracciatella/default.nix')
-rw-r--r-- | pkgs/games/ja2-stracciatella/default.nix | 56 |
1 files changed, 34 insertions, 22 deletions
diff --git a/pkgs/games/ja2-stracciatella/default.nix b/pkgs/games/ja2-stracciatella/default.nix index 4dfcc53d339..4f186c3c60a 100644 --- a/pkgs/games/ja2-stracciatella/default.nix +++ b/pkgs/games/ja2-stracciatella/default.nix @@ -1,45 +1,57 @@ -{ stdenv, fetchFromGitHub, cmake, SDL2, boost, fltk, rustPlatform }: +{ stdenv, lib, fetchurl, fetchFromGitHub, cmake, python, rustPlatform, SDL2, fltk, rapidjson, gtest, Carbon, Cocoa }: let - version = "0.16.1"; + version = "0.17.0"; src = fetchFromGitHub { owner = "ja2-stracciatella"; repo = "ja2-stracciatella"; rev = "v${version}"; - sha256 = "1pyn23syg70kiyfbs3pdlq0ixd2bxhncbamnic43rym3dmd52m29"; - }; - lockfile = ./Cargo.lock; - libstracciatellaSrc = stdenv.mkDerivation { - name = "libstracciatella-${version}-src"; - src = "${src}/rust"; - installPhase = '' - mkdir -p $out - cp -R ./* $out/ - cp ${lockfile} $out/Cargo.lock - ''; + sha256 = "0m6rvgkba29jy3yq5hs1sn26mwrjl6mamqnv4plrid5fqaivhn6j"; }; libstracciatella = rustPlatform.buildRustPackage { pname = "libstracciatella"; inherit version; - src = libstracciatellaSrc; - cargoSha256 = "15djs4xaz4y1hpfyfqxdgdasxr0b5idy9i5a7c8cmh0jkxjv8bqc"; - doCheck = false; + 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"; }; in stdenv.mkDerivation { pname = "ja2-stracciatella"; - inherit src; - inherit version; + inherit src version; - nativeBuildInputs = [ cmake ]; - buildInputs = [ SDL2 fltk boost ]; + nativeBuildInputs = [ cmake python ]; + buildInputs = [ SDL2 fltk rapidjson gtest ] ++ lib.optionals stdenv.isDarwin [ Carbon Cocoa ]; patches = [ ./remove-rust-buildstep.patch ]; preConfigure = '' - sed -i -e 's|rust-stracciatella|${libstracciatella}/lib/libstracciatella.so|g' CMakeLists.txt - cmakeFlagsArray+=("-DEXTRA_DATA_DIR=$out/share/ja2") + # 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 ''; meta = { |