2016-01-19 22:44:33 +01:00
|
|
|
{ stdenv, lib, buildEnv, dwarf-fortress-original, substituteAll
|
2016-01-12 18:56:59 +01:00
|
|
|
, enableDFHack ? false, dfhack
|
2016-01-19 22:44:33 +01:00
|
|
|
, themes ? {}
|
|
|
|
, theme ? null
|
2016-01-12 18:56:59 +01:00
|
|
|
}:
|
|
|
|
|
2016-01-19 22:44:33 +01:00
|
|
|
let
|
|
|
|
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
|
|
|
|
++ lib.optional enableDFHack dfhack
|
|
|
|
++ [ dwarf-fortress-original ];
|
|
|
|
|
|
|
|
env = buildEnv {
|
|
|
|
name = "dwarf-fortress-env-${dwarf-fortress-original.dfVersion}";
|
|
|
|
paths = pkgs;
|
|
|
|
ignoreCollisions = true;
|
|
|
|
postBuild = lib.optionalString enableDFHack ''
|
|
|
|
# #4621
|
|
|
|
if [ -L "$out/hack" ]; then
|
|
|
|
rm $out/hack
|
|
|
|
mkdir $out/hack
|
|
|
|
for i in ${dfhack}/hack/*; do
|
|
|
|
ln -s $i $out/hack
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
rm $out/hack/symbols.xml
|
|
|
|
substitute ${dfhack}/hack/symbols.xml $out/hack/symbols.xml \
|
2016-01-23 21:57:58 +01:00
|
|
|
--replace $(cat ${dwarf-fortress-original}/hash.md5.orig) \
|
|
|
|
$(cat ${dwarf-fortress-original}/hash.md5)
|
2016-01-19 22:44:33 +01:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
in
|
|
|
|
|
|
|
|
assert lib.all (x: x.dfVersion == dwarf-fortress-original.dfVersion) pkgs;
|
2016-01-12 18:56:59 +01:00
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
name = "dwarf-fortress-${dwarf-fortress-original.dfVersion}";
|
|
|
|
|
|
|
|
dfInit = substituteAll {
|
|
|
|
name = "dwarf-fortress-init";
|
|
|
|
src = ./dwarf-fortress-init.in;
|
2016-01-19 22:44:33 +01:00
|
|
|
inherit env;
|
2016-01-12 18:56:59 +01:00
|
|
|
};
|
2016-01-19 22:44:33 +01:00
|
|
|
|
|
|
|
runDF = ./dwarf-fortress.in;
|
|
|
|
runDFHack = ./dfhack.in;
|
2016-01-12 18:56:59 +01: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 22:44:33 +01:00
|
|
|
--subst-var dfInit
|
2016-01-12 18:56:59 +01:00
|
|
|
chmod 755 $out/bin/dfhack
|
|
|
|
'';
|
|
|
|
|
|
|
|
preferLocalBuild = true;
|
|
|
|
}
|