nixpkgs/pkgs/games/dwarf-fortress/default.nix

91 lines
2.9 KiB
Nix
Raw Normal View History

{stdenv, fetchurl, SDL, SDL_image, SDL_ttf, gnomegtk, glib, mesa, openal, glibc, libsndfile}:
assert stdenv.system == "i686-linux";
stdenv.mkDerivation rec {
name = "dwarf-fortress-0.31.16";
src = fetchurl {
url = "http://www.bay12games.com/dwarves/df_31_16_linux.tar.bz2";
sha256 = "04pyxyigrrclbpxdx3wryisgy5xraz0s7rsxr2kp4i136479f2r4";
};
phases = "unpackPhase patchPhase installPhase";
/* :TODO: Game options should be configurable by patching the default configuration files */
permission = ./df_permission;
installPhase = ''
set -x
ensureDir $out/bin
ensureDir $out/share/df_linux
cp -r * $out/share/df_linux
cp $permission $out/share/df_linux/nix_permission
patchelf --set-interpreter ${glibc}/lib/ld-linux.so.2 $out/share/df_linux/libs/Dwarf_Fortress
ln -s ${libsndfile}/lib/libsndfile.so $out/share/df_linux/libs/
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 sturctor reflecting the original distribution in the user directory
# Now link in the static data
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 data directory
mkdir \$DF_DIR/data
for i in $out/share/df_linux/data/*
do
ln -s \$i \$DF_DIR/data/
done
# index as of 0.31.16 opened in read/write mode
# this is a hack to work around this
rm \$DF_DIR/data/index
cp $out/share/df_linux/data/index \$DF_DIR/data/index
chmod u+w \$DF_DIR/data/index
# initial_movies files are as of 0.31.16 opened in read/write mode instead of read-only mode
# this is a hack to work around this
rm \$DF_DIR/data/initial_movies
cp -rf $out/share/df_linux/data/initial_movies \$DF_DIR/data/
chmod -R u+w \$DF_DIR/data/initial_movies
# announcement files are as of 0.31.16 opened in read/write mode instead of read-only mode
# this is a hack to work around this
rm \$DF_DIR/data/announcement
cp -rf $out/share/df_linux/data/announcement \$DF_DIR/data/
chmod -R u+w \$DF_DIR/data/announcement
# link in persistant data
mkdir -p \$DF_DIR/save
ln -s \$DF_DIR/save \$DF_DIR/data/
# now run Dwarf Fortress!
export LD_LIBRARY_PATH=\$DF_DIR/df_linux/libs/:${SDL}/lib:${SDL_image}/lib/:${SDL_ttf}/lib/:${gnomegtk}/lib/:${glib}/lib/:${mesa}/lib/:${openal}/lib/
\$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];
};
}