2018-07-21 01:44:44 +01:00
|
|
|
{ stdenv, buildEnv, lib, fetchFromGitHub, cmake, writeScriptBin
|
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
|
2018-07-12 09:42:52 +01:00
|
|
|
, dfVersion
|
2016-01-12 17:56:59 +00:00
|
|
|
}:
|
|
|
|
|
2018-07-12 09:42:52 +01:00
|
|
|
with lib;
|
|
|
|
|
2016-01-12 17:56:59 +00:00
|
|
|
let
|
2018-09-09 08:12:36 +01:00
|
|
|
dfhack-releases = {
|
|
|
|
"0.43.05" = {
|
|
|
|
dfHackRelease = "0.43.05-r3.1";
|
|
|
|
sha256 = "1ds366i0qcfbn62w9qv98lsqcrm38npzgvcr35hf6ihqa6nc6xrl";
|
|
|
|
xmlRev = "860a9041a75305609643d465123a4b598140dd7f";
|
|
|
|
prerelease = false;
|
|
|
|
};
|
|
|
|
"0.44.05" = {
|
|
|
|
dfHackRelease = "0.44.05-r2";
|
|
|
|
sha256 = "1cwifdhi48a976xc472nf6q2k0ibwqffil5a4llcymcxdbgxdcc9";
|
|
|
|
xmlRev = "2794f8a6d7405d4858bac486a0bb17b94740c142";
|
|
|
|
prerelease = false;
|
|
|
|
};
|
|
|
|
"0.44.09" = {
|
|
|
|
dfHackRelease = "0.44.09-r1";
|
|
|
|
sha256 = "1nkfaa43pisbyik5inj5q2hja2vza5lwidg5z02jyh136jm64hwk";
|
|
|
|
xmlRev = "3c0bf63674d5430deadaf7befaec42f0ec1e8bc5";
|
|
|
|
prerelease = false;
|
|
|
|
};
|
|
|
|
"0.44.10" = {
|
|
|
|
dfHackRelease = "0.44.10-r2";
|
|
|
|
sha256 = "19bxsghxzw3bilhr8sm4axz7p7z8lrvbdsd1vdjf5zbg04rs866i";
|
|
|
|
xmlRev = "321bd48b10c4c3f694cc801a7dee6be392c09b7b";
|
|
|
|
prerelease = false;
|
|
|
|
};
|
|
|
|
"0.44.11" = {
|
|
|
|
dfHackRelease = "0.44.11-beta2.1";
|
|
|
|
sha256 = "1jgwcqg9m1ybv3szgnklp6zfpiw5mswla464dlj2gfi5v82zqbv2";
|
|
|
|
xmlRev = "f27ebae6aa8fb12c46217adec5a812cd49a905c8";
|
|
|
|
prerelease = true;
|
|
|
|
};
|
|
|
|
"0.44.12" = {
|
|
|
|
dfHackRelease = "0.44.12-r1";
|
|
|
|
sha256 = "0j03lq6j6w378z6cvm7jspxc7hhrqm8jaszlq0mzfvap0k13fgyy";
|
|
|
|
xmlRev = "23500e4e9bd1885365d0a2ef1746c321c1dd5094";
|
|
|
|
prerelease = false;
|
|
|
|
};
|
|
|
|
};
|
2018-07-12 09:42:52 +01:00
|
|
|
|
|
|
|
release = if hasAttr dfVersion dfhack-releases
|
|
|
|
then getAttr dfVersion dfhack-releases
|
|
|
|
else throw "[DFHack] Unsupported Dwarf Fortress version: ${dfVersion}";
|
|
|
|
|
|
|
|
version = release.dfHackRelease;
|
|
|
|
|
|
|
|
warning = if release.prerelease then builtins.trace "[DFHack] Version ${version} is a prerelease. Careful!"
|
|
|
|
else null;
|
2016-08-13 01:12:20 +01:00
|
|
|
|
2016-04-30 01:02:26 +01:00
|
|
|
# revision of library/xml submodule
|
2018-07-12 09:42:52 +01:00
|
|
|
xmlRev = release.xmlRev;
|
2016-01-12 17:56:59 +00:00
|
|
|
|
2016-11-23 23:51:51 +00:00
|
|
|
arch =
|
2018-08-20 20:11:29 +01:00
|
|
|
if stdenv.hostPlatform.system == "x86_64-linux" then "64"
|
|
|
|
else if stdenv.hostPlatform.system == "i686-linux" then "32"
|
2016-11-23 23:51:51 +00:00
|
|
|
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"
|
2018-07-15 08:02:50 +01:00
|
|
|
elif [ "$*" = "describe --tags --abbrev=8 --long" ]; then
|
|
|
|
echo "${version}-unknown"
|
|
|
|
elif [ "$*" = "describe --tags --abbrev=8 --exact-match" ]; then
|
|
|
|
echo "${version}"
|
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";
|
2018-07-12 09:42:52 +01:00
|
|
|
rev = release.dfHackRelease;
|
|
|
|
sha256 = release.sha256;
|
2018-07-05 16:36:27 +01:00
|
|
|
fetchSubmodules = true;
|
|
|
|
};
|
2016-01-12 17:56:59 +00:00
|
|
|
|
2018-06-19 13:09:40 +01:00
|
|
|
patches = [ ./fix-stonesense.patch ];
|
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
|
|
|
};
|
|
|
|
}
|