2018-07-05 16:36:27 +01:00
|
|
|
{ stdenv, buildEnv, hostPlatform, lib, fetchurl, fetchFromGitHub, cmake, writeScriptBin, callPackage
|
2017-10-01 20:26:51 +01:00
|
|
|
, perl, XMLLibXML, XMLLibXSLT, zlib
|
2018-02-24 13:12:44 +00:00
|
|
|
, enableStoneSense ? false, allegro5, libGLU_combined
|
2018-07-05 16:36:27 +01:00
|
|
|
, enableTWBT ? true, twbt
|
2018-06-11 00:10:25 +01:00
|
|
|
, SDL
|
2016-01-12 17:56:59 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
2018-06-30 10:08:56 +01:00
|
|
|
dfVersion = "0.44.11";
|
|
|
|
version = "${dfVersion}-alpha1";
|
2016-08-13 01:12:20 +01:00
|
|
|
|
2016-04-30 01:02:26 +01:00
|
|
|
# revision of library/xml submodule
|
2018-06-30 10:08:56 +01:00
|
|
|
xmlRev = "853bd161270f50b21fe4b751de339458f78f56d6";
|
2016-01-12 17:56:59 +00:00
|
|
|
|
2016-11-23 23:51:51 +00:00
|
|
|
arch =
|
|
|
|
if stdenv.system == "x86_64-linux" then "64"
|
|
|
|
else if stdenv.system == "i686-linux" then "32"
|
|
|
|
else throw "Unsupported architecture";
|
|
|
|
|
2016-01-12 17:56:59 +00:00
|
|
|
fakegit = writeScriptBin "git" ''
|
|
|
|
#! ${stdenv.shell}
|
|
|
|
if [ "$*" = "describe --tags --long" ]; then
|
2016-08-13 01:12:20 +01:00
|
|
|
echo "${version}-unknown"
|
2016-01-12 17:56:59 +00:00
|
|
|
elif [ "$*" = "rev-parse HEAD" ]; then
|
2016-03-03 12:33:13 +00:00
|
|
|
if [ "$(dirname "$(pwd)")" = "xml" ]; then
|
|
|
|
echo "${xmlRev}"
|
|
|
|
else
|
2018-06-06 23:07:42 +01:00
|
|
|
echo "refs/tags/${version}"
|
2016-03-03 12:33:13 +00:00
|
|
|
fi
|
|
|
|
elif [ "$*" = "rev-parse HEAD:library/xml" ]; then
|
|
|
|
echo "${xmlRev}"
|
2016-01-12 17:56:59 +00:00
|
|
|
else
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
'';
|
|
|
|
|
2018-07-05 16:36:27 +01:00
|
|
|
dfhack = stdenv.mkDerivation rec {
|
|
|
|
name = "dfhack-base-${version}";
|
2016-01-12 17:56:59 +00:00
|
|
|
|
2018-07-05 16:36:27 +01:00
|
|
|
# Beware of submodules
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "DFHack";
|
|
|
|
repo = "dfhack";
|
|
|
|
sha256 = "1vzrpdw0pn18calayf9dwqpyg37cb7wkzkvskxjx9nak5ilxzywm";
|
|
|
|
rev = version;
|
|
|
|
fetchSubmodules = true;
|
|
|
|
};
|
2016-01-12 17:56:59 +00:00
|
|
|
|
2018-07-05 16:36:27 +01:00
|
|
|
nativeBuildInputs = [ cmake perl XMLLibXML XMLLibXSLT fakegit ];
|
|
|
|
# We don't use system libraries because dfhack needs old C++ ABI.
|
|
|
|
buildInputs = [ zlib SDL ]
|
|
|
|
++ lib.optionals enableStoneSense [ allegro5 libGLU_combined ];
|
2016-11-23 23:51:51 +00:00
|
|
|
|
2018-07-05 16:36:27 +01:00
|
|
|
preConfigure = ''
|
|
|
|
# Trick build system into believing we have .git
|
|
|
|
mkdir -p .git/modules/library/xml
|
|
|
|
touch .git/index .git/modules/library/xml/index
|
|
|
|
'';
|
2017-07-27 13:54:23 +01:00
|
|
|
|
2018-07-05 16:36:27 +01:00
|
|
|
preBuild = ''
|
|
|
|
export LD_LIBRARY_PATH="$PWD/depends/protobuf:$LD_LIBRARY_PATH"
|
|
|
|
'';
|
2016-01-12 17:56:59 +00:00
|
|
|
|
2018-07-05 16:36:27 +01:00
|
|
|
cmakeFlags = [ "-DDFHACK_BUILD_ARCH=${arch}" "-DDOWNLOAD_RUBY=OFF" ]
|
|
|
|
++ lib.optionals enableStoneSense [ "-DBUILD_STONESENSE=ON" "-DSTONESENSE_INTERNAL_SO=OFF" ];
|
2016-08-13 01:12:20 +01:00
|
|
|
|
2018-07-05 16:36:27 +01:00
|
|
|
enableParallelBuilding = true;
|
|
|
|
};
|
|
|
|
in
|
|
|
|
|
|
|
|
buildEnv {
|
|
|
|
name = "dfhack-${version}";
|
2016-01-12 17:56:59 +00:00
|
|
|
|
2016-08-13 01:12:20 +01:00
|
|
|
passthru = { inherit version dfVersion; };
|
2016-01-12 17:56:59 +00:00
|
|
|
|
2018-07-05 16:36:27 +01:00
|
|
|
paths = [ dfhack ] ++ lib.optionals enableTWBT [ twbt.lib ];
|
|
|
|
|
2016-01-12 17:56:59 +00:00
|
|
|
meta = with stdenv.lib; {
|
|
|
|
description = "Memory hacking library for Dwarf Fortress and a set of tools that use it";
|
2017-08-01 21:03:30 +01:00
|
|
|
homepage = https://github.com/DFHack/dfhack/;
|
2016-01-12 17:56:59 +00:00
|
|
|
license = licenses.zlib;
|
2016-11-23 23:51:51 +00:00
|
|
|
platforms = [ "x86_64-linux" "i686-linux" ];
|
2018-06-30 10:08:56 +01:00
|
|
|
maintainers = with maintainers; [ robbinch a1russell abbradar numinit ];
|
2016-01-12 17:56:59 +00:00
|
|
|
};
|
|
|
|
}
|