2015-12-08 14:45:44 +00:00
|
|
|
{ stdenv, lib, fetchurl, writeScript, ncurses, gzip, flex, bison }:
|
2015-06-29 11:19:12 +00:00
|
|
|
|
2015-12-08 14:45:44 +00:00
|
|
|
let
|
|
|
|
platform =
|
|
|
|
if lib.elem stdenv.system lib.platforms.unix then "unix"
|
|
|
|
else abort "Unknown platform for NetHack";
|
|
|
|
unixHint =
|
|
|
|
if stdenv.isLinux then "linux"
|
|
|
|
# We probably want something different for Darwin
|
|
|
|
else "unix";
|
2015-12-08 15:10:53 +00:00
|
|
|
userDir = "~/.config/nethack";
|
2015-12-08 14:45:44 +00:00
|
|
|
|
|
|
|
in stdenv.mkDerivation {
|
|
|
|
name = "nethack-3.6.0";
|
2015-06-29 11:19:12 +00:00
|
|
|
|
2009-05-12 04:27:10 +00:00
|
|
|
src = fetchurl {
|
2015-12-08 14:45:44 +00:00
|
|
|
url = "mirror://sourceforge/nethack/nethack-360-src.tgz";
|
|
|
|
sha256 = "12mi5kgqw3q029y57pkg3gnp930p7yvlqi118xxdif2qhj6nkphs";
|
2009-05-12 04:27:10 +00:00
|
|
|
};
|
|
|
|
|
2015-06-29 11:19:12 +00:00
|
|
|
buildInputs = [ ncurses ];
|
|
|
|
|
|
|
|
nativeBuildInputs = [ flex bison ];
|
2009-05-12 04:27:10 +00:00
|
|
|
|
2015-12-08 14:45:44 +00:00
|
|
|
makeFlags = [ "PREFIX=$(out)" ];
|
2009-05-12 04:27:10 +00:00
|
|
|
|
2015-12-08 14:45:44 +00:00
|
|
|
configurePhase = ''
|
|
|
|
cd sys/${platform}
|
|
|
|
${lib.optionalString (platform == "unix") ''
|
|
|
|
sed -e '/^ *cd /d' -i nethack.sh
|
|
|
|
${lib.optionalString (unixHint == "linux") ''
|
|
|
|
sed \
|
|
|
|
-e 's,/bin/gzip,${gzip}/bin/gzip,g' \
|
|
|
|
-e 's,^WINTTYLIB=.*,WINTTYLIB=-lncurses,' \
|
|
|
|
-i hints/linux
|
|
|
|
''}
|
|
|
|
sh setup.sh hints/${unixHint}
|
|
|
|
''}
|
|
|
|
cd ../..
|
2009-05-12 04:27:10 +00:00
|
|
|
|
2015-12-08 14:45:44 +00:00
|
|
|
sed -e '/define CHDIR/d' -i include/config.h
|
|
|
|
sed \
|
|
|
|
-e 's/^YACC *=.*/YACC = bison -y/' \
|
|
|
|
-e 's/^LEX *=.*/LEX = flex/' \
|
|
|
|
-i util/Makefile
|
2015-06-29 11:19:12 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
postInstall = ''
|
2015-12-08 14:45:44 +00:00
|
|
|
mkdir -p $out/games/lib/nethackuserdir
|
2015-06-29 11:19:12 +00:00
|
|
|
for i in logfile perm record save; do
|
2015-12-08 14:45:44 +00:00
|
|
|
mv $out/games/lib/nethackdir/$i $out/games/lib/nethackuserdir
|
2015-06-29 11:19:12 +00:00
|
|
|
done
|
|
|
|
|
2012-01-18 20:16:00 +00:00
|
|
|
mkdir -p $out/bin
|
2015-06-29 11:19:12 +00:00
|
|
|
cat <<EOF >$out/bin/nethack
|
2015-12-08 15:10:53 +00:00
|
|
|
#! ${stdenv.shell} -e
|
2015-06-29 11:19:12 +00:00
|
|
|
|
2015-12-08 15:10:53 +00:00
|
|
|
if [ ! -d ${userDir} ]; then
|
|
|
|
mkdir -p ${userDir}
|
|
|
|
cp -r $out/games/lib/nethackuserdir/* ${userDir}
|
|
|
|
chmod -R +w ${userDir}
|
|
|
|
fi
|
2015-06-29 11:19:12 +00:00
|
|
|
|
2015-12-08 15:10:53 +00:00
|
|
|
RUNDIR=\$(mktemp -td nethack.\$USER.XXXXX)
|
2015-06-29 11:19:12 +00:00
|
|
|
|
2015-12-08 15:10:53 +00:00
|
|
|
cleanup() {
|
|
|
|
rm -rf \$RUNDIR
|
|
|
|
}
|
|
|
|
trap cleanup EXIT
|
|
|
|
|
|
|
|
cd \$RUNDIR
|
|
|
|
for i in ${userDir}/*; do
|
|
|
|
ln -s \$i \$(basename \$i)
|
|
|
|
done
|
|
|
|
for i in $out/games/lib/nethackdir/*; do
|
|
|
|
ln -s \$i \$(basename \$i)
|
|
|
|
done
|
|
|
|
$out/games/nethack
|
2015-06-29 11:19:12 +00:00
|
|
|
EOF
|
|
|
|
chmod +x $out/bin/nethack
|
|
|
|
'';
|
|
|
|
|
|
|
|
meta = with stdenv.lib; {
|
|
|
|
description = "Rogue-like game";
|
|
|
|
homepage = "http://nethack.org/";
|
|
|
|
license = "nethack";
|
|
|
|
platforms = platforms.unix;
|
|
|
|
maintainers = with maintainers; [ abbradar ];
|
2009-05-12 04:27:10 +00:00
|
|
|
};
|
|
|
|
}
|