2016-01-19 21:44:33 +00:00
|
|
|
{ stdenv, lib, buildEnv, dwarf-fortress-original, substituteAll
|
2016-01-12 17:56:59 +00:00
|
|
|
, enableDFHack ? false, dfhack
|
2017-06-19 01:48:02 +01:00
|
|
|
, enableSoundSense ? false, soundSense, jdk
|
2017-10-01 20:26:51 +01:00
|
|
|
, enableStoneSense ? false
|
2016-01-19 21:44:33 +00:00
|
|
|
, themes ? {}
|
|
|
|
, theme ? null
|
2016-01-12 17:56:59 +00:00
|
|
|
}:
|
|
|
|
|
2016-01-19 21:44:33 +00:00
|
|
|
let
|
2017-10-01 20:26:51 +01:00
|
|
|
dfhack_ = dfhack.override {
|
|
|
|
inherit enableStoneSense;
|
|
|
|
};
|
|
|
|
|
2016-01-19 21:44:33 +00:00
|
|
|
ptheme =
|
|
|
|
if builtins.isString theme
|
|
|
|
then builtins.getAttr theme themes
|
|
|
|
else theme;
|
|
|
|
|
|
|
|
# These are in inverse order for first packages to override the next ones.
|
|
|
|
pkgs = lib.optional (theme != null) ptheme
|
2017-10-01 20:26:51 +01:00
|
|
|
++ lib.optional enableDFHack dfhack_
|
2017-06-19 01:48:02 +01:00
|
|
|
++ lib.optional enableSoundSense soundSense
|
2016-01-19 21:44:33 +00:00
|
|
|
++ [ dwarf-fortress-original ];
|
|
|
|
|
|
|
|
env = buildEnv {
|
|
|
|
name = "dwarf-fortress-env-${dwarf-fortress-original.dfVersion}";
|
2016-11-23 23:51:51 +00:00
|
|
|
|
2016-01-19 21:44:33 +00:00
|
|
|
paths = pkgs;
|
2017-06-19 01:48:02 +01:00
|
|
|
pathsToLink = [ "/" "/hack" "/hack/scripts" ];
|
2016-01-19 21:44:33 +00:00
|
|
|
ignoreCollisions = true;
|
2016-11-23 23:51:51 +00:00
|
|
|
|
2016-01-19 21:44:33 +00:00
|
|
|
postBuild = lib.optionalString enableDFHack ''
|
|
|
|
rm $out/hack/symbols.xml
|
2017-10-01 20:26:51 +01:00
|
|
|
substitute ${dfhack_}/hack/symbols.xml $out/hack/symbols.xml \
|
2016-01-23 20:57:58 +00:00
|
|
|
--replace $(cat ${dwarf-fortress-original}/hash.md5.orig) \
|
|
|
|
$(cat ${dwarf-fortress-original}/hash.md5)
|
2016-01-19 21:44:33 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
in
|
|
|
|
|
2016-01-12 17:56:59 +00:00
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
name = "dwarf-fortress-${dwarf-fortress-original.dfVersion}";
|
|
|
|
|
2017-12-06 23:53:24 +00:00
|
|
|
compatible = lib.all (x: assert (x.dfVersion == dwarf-fortress-original.dfVersion); true) pkgs;
|
|
|
|
|
2016-01-12 17:56:59 +00:00
|
|
|
dfInit = substituteAll {
|
|
|
|
name = "dwarf-fortress-init";
|
|
|
|
src = ./dwarf-fortress-init.in;
|
2016-01-19 21:44:33 +00:00
|
|
|
inherit env;
|
2016-01-12 17:56:59 +00:00
|
|
|
};
|
2016-01-19 21:44:33 +00:00
|
|
|
|
|
|
|
runDF = ./dwarf-fortress.in;
|
|
|
|
runDFHack = ./dfhack.in;
|
2017-06-19 01:48:02 +01:00
|
|
|
runSoundSense = ./soundSense.in;
|
2016-01-12 17:56:59 +00:00
|
|
|
|
|
|
|
buildCommand = ''
|
|
|
|
mkdir -p $out/bin
|
|
|
|
|
|
|
|
substitute $runDF $out/bin/dwarf-fortress \
|
|
|
|
--subst-var-by stdenv_shell ${stdenv.shell} \
|
|
|
|
--subst-var dfInit
|
|
|
|
chmod 755 $out/bin/dwarf-fortress
|
|
|
|
'' + lib.optionalString enableDFHack ''
|
|
|
|
substitute $runDFHack $out/bin/dfhack \
|
|
|
|
--subst-var-by stdenv_shell ${stdenv.shell} \
|
2016-01-19 21:44:33 +00:00
|
|
|
--subst-var dfInit
|
2016-01-12 17:56:59 +00:00
|
|
|
chmod 755 $out/bin/dfhack
|
2017-06-19 01:48:02 +01:00
|
|
|
'' + lib.optionalString enableSoundSense ''
|
|
|
|
substitute $runSoundSense $out/bin/soundsense \
|
|
|
|
--subst-var-by stdenv_shell ${stdenv.shell} \
|
|
|
|
--subst-var-by jre ${jdk.jre} \
|
|
|
|
--subst-var dfInit
|
|
|
|
chmod 755 $out/bin/soundsense
|
2016-01-12 17:56:59 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
preferLocalBuild = true;
|
|
|
|
}
|