2014-08-21 02:50:09 +01:00
|
|
|
{ stdenv, fetchgit, fetchurl, cmake, glew, ncurses, SDL, SDL_image, SDL_ttf, gtk2, glib, mesa, openal, pango, atk, gdk_pixbuf, glibc, libsndfile
|
|
|
|
, copyDataDirectory ? true }:
|
|
|
|
|
|
|
|
/* set copyDataDirectory as true by default since df 40 does not seem to run without it */
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
srcs = {
|
|
|
|
df_unfuck = fetchgit {
|
|
|
|
url = "https://github.com/svenstaro/dwarf_fortress_unfuck";
|
2014-09-18 19:41:54 +01:00
|
|
|
rev = "044b266ce3e03b54a4228d51d6b75d70963debc9";
|
|
|
|
sha256 = "0xc839zmg1bqyrdirhy2ixm8i58q7nwhyi86h60qmrfdg3bsnnpr";
|
2014-08-21 02:50:09 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
df = fetchurl {
|
2014-09-18 19:41:54 +01:00
|
|
|
url = "http://www.bay12games.com/dwarves/df_40_13_linux.tar.bz2";
|
|
|
|
sha256 = "1azsxgjc1fh8i041p6i7dmvdk0v3xpmhg44lmimlrs78a08h4z61";
|
2014-08-21 02:50:09 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
in
|
2014-07-24 03:41:30 +01:00
|
|
|
|
|
|
|
assert stdenv.system == "i686-linux";
|
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
2014-09-18 19:41:54 +01:00
|
|
|
name = "dwarf-fortress-0.40.13";
|
2014-07-24 03:41:30 +01:00
|
|
|
|
|
|
|
|
2014-08-21 02:50:09 +01:00
|
|
|
buildInputs = [ SDL SDL_image SDL_ttf gtk2 glib glew mesa ncurses openal glibc libsndfile pango atk cmake gdk_pixbuf];
|
|
|
|
src = "${srcs.df_unfuck} ${srcs.df}";
|
|
|
|
phases = "unpackPhase patchPhase configurePhase buildPhase installPhase";
|
|
|
|
|
|
|
|
sourceRoot = "git-export";
|
|
|
|
|
|
|
|
cmakeFlags = [
|
|
|
|
"-DGTK2_GLIBCONFIG_INCLUDE_DIR=${glib}/lib/glib-2.0/include"
|
|
|
|
"-DGTK2_GDKCONFIG_INCLUDE_DIR=${gtk2}/lib/gtk-2.0/include"
|
|
|
|
];
|
2014-07-24 03:41:30 +01:00
|
|
|
|
|
|
|
/* :TODO: Game options should be configurable by patching the default configuration files */
|
|
|
|
|
|
|
|
permission = ./df_permission;
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
set -x
|
|
|
|
mkdir -p $out/bin
|
|
|
|
mkdir -p $out/share/df_linux
|
2014-08-21 02:50:09 +01:00
|
|
|
cd ../../
|
|
|
|
cp -r ./df_linux/* $out/share/df_linux
|
|
|
|
rm $out/share/df_linux/libs/lib*
|
|
|
|
patchelf --set-rpath "${stdenv.lib.makeLibraryPath [ stdenv.gcc.gcc stdenv.glibc ]}:$out/share/df_linux/libs" $out/share/df_linux/libs/Dwarf_Fortress
|
|
|
|
cp -f ./git-export/build/libgraphics.so $out/share/df_linux/libs/libgraphics.so
|
|
|
|
|
2014-07-24 03:41:30 +01:00
|
|
|
cp $permission $out/share/df_linux/nix_permission
|
|
|
|
|
|
|
|
patchelf --set-interpreter ${glibc}/lib/ld-linux.so.2 $out/share/df_linux/libs/Dwarf_Fortress
|
|
|
|
|
|
|
|
cat > $out/bin/dwarf-fortress << EOF
|
|
|
|
#!${stdenv.shell}
|
|
|
|
export DF_DIR="\$HOME/.config/df_linux"
|
|
|
|
if [ -n "\$XDG_DATA_HOME" ]
|
|
|
|
then export DF_DIR="\$XDG_DATA_HOME/df_linux"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Recreate a directory structure reflecting the original
|
|
|
|
# distribution in the user directory (for modding support)
|
|
|
|
${if copyDataDirectory then ''
|
|
|
|
if [ ! -d "\$DF_DIR" ];
|
|
|
|
then
|
|
|
|
mkdir -p \$DF_DIR
|
|
|
|
cp -r $out/share/df_linux/* \$DF_DIR/
|
|
|
|
chmod -R u+rw \$DF_DIR/
|
|
|
|
fi
|
|
|
|
'' else ''
|
|
|
|
# Link in the static stuff
|
|
|
|
mkdir -p \$DF_DIR
|
|
|
|
ln -sf $out/share/df_linux/libs \$DF_DIR/
|
|
|
|
ln -sf $out/share/df_linux/raw \$DF_DIR/
|
|
|
|
ln -sf $out/share/df_linux/df \$DF_DIR/
|
|
|
|
|
|
|
|
# Delete old data directory
|
|
|
|
rm -rf \$DF_DIR/data
|
|
|
|
|
|
|
|
# Link in the static data directory
|
|
|
|
mkdir \$DF_DIR/data
|
|
|
|
for i in $out/share/df_linux/data/*
|
|
|
|
do
|
|
|
|
ln -s \$i \$DF_DIR/data/
|
|
|
|
done
|
|
|
|
|
|
|
|
# link in persistant data
|
|
|
|
mkdir -p \$DF_DIR/save
|
|
|
|
ln -s \$DF_DIR/save \$DF_DIR/data/
|
|
|
|
''}
|
|
|
|
|
|
|
|
# now run Dwarf Fortress!
|
2014-08-21 02:50:09 +01:00
|
|
|
export LD_LIBRARY_PATH=\${stdenv.gcc}/lib:${SDL}/lib:${SDL_image}/lib/:${SDL_ttf}/lib/:${gtk2}/lib/:${glib}/lib/:${mesa}/lib/:${openal}/lib/:${libsndfile}/lib:$DF_DIR/df_linux/libs/
|
2014-07-24 03:41:30 +01:00
|
|
|
\$DF_DIR/df "\$@"
|
|
|
|
EOF
|
|
|
|
|
|
|
|
chmod +x $out/bin/dwarf-fortress
|
|
|
|
'';
|
|
|
|
|
|
|
|
meta = {
|
|
|
|
description = "control a dwarven outpost or an adventurer in a randomly generated, persistent world";
|
|
|
|
homepage = http://www.bay12games.com/dwarves;
|
|
|
|
license = "unfree-redistributable";
|
|
|
|
maintainers = [stdenv.lib.maintainers.roconnor];
|
|
|
|
};
|
|
|
|
}
|