diff options
Diffstat (limited to 'pkgs/games/nethack/default.nix')
-rw-r--r-- | pkgs/games/nethack/default.nix | 97 |
1 files changed, 56 insertions, 41 deletions
diff --git a/pkgs/games/nethack/default.nix b/pkgs/games/nethack/default.nix index e5057c27e99..05c39fb2f2b 100644 --- a/pkgs/games/nethack/default.nix +++ b/pkgs/games/nethack/default.nix @@ -1,70 +1,85 @@ -{ stdenv, fetchurl, writeScript, ncurses, gzip, flex, bison }: +{ stdenv, lib, fetchurl, writeScript, ncurses, gzip, flex, bison }: -stdenv.mkDerivation rec { - name = "nethack-3.4.3"; +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"; + userDir = "~/.config/nethack"; + +in stdenv.mkDerivation { + name = "nethack-3.6.0"; src = fetchurl { - url = "mirror://sourceforge/nethack/nethack-343-src.tgz"; - sha256 = "1r3ghqj82j0bar62z3b0lx9hhx33pj7p1ppxr2hg8bgfm79c6fdv"; + url = "mirror://sourceforge/nethack/nethack-360-src.tgz"; + sha256 = "12mi5kgqw3q029y57pkg3gnp930p7yvlqi118xxdif2qhj6nkphs"; }; buildInputs = [ ncurses ]; nativeBuildInputs = [ flex bison ]; - preBuild = '' - ( cd sys/unix ; sh setup.sh ) - - sed -e '/define COMPRESS/d' -i include/config.h - sed -e '1i\#define COMPRESS "${gzip}/bin/gzip"' -i include/config.h - sed -e '1i\#define COMPRESS_EXTENSION ".gz"' -i include/config.h - sed -e '/define CHDIR/d' -i include/config.h - - sed -e '/extern char [*]tparm/d' -i win/tty/*.c - - sed -e 's/-ltermlib/-lncurses/' -i src/Makefile - sed -e 's/^YACC *=.*/YACC = bison -y/' -i util/Makefile - sed -e 's/^LEX *=.*/LEX = flex/' -i util/Makefile + makeFlags = [ "PREFIX=$(out)" ]; - sed -re 's@^(CH...).*@\1 = true@' -i Makefile + 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 ../.. - sed -e '/^ *cd /d' -i sys/unix/nethack.sh + sed -e '/define CHDIR/d' -i include/config.h + sed \ + -e 's/^YACC *=.*/YACC = bison -y/' \ + -e 's/^LEX *=.*/LEX = flex/' \ + -i util/Makefile ''; postInstall = '' + mkdir -p $out/games/lib/nethackuserdir for i in logfile perm record save; do - rm -rf $out/games/lib/nethackdir/$i + mv $out/games/lib/nethackdir/$i $out/games/lib/nethackuserdir done mkdir -p $out/bin cat <<EOF >$out/bin/nethack - #! ${stdenv.shell} -e - if [ ! -d ~/.nethack ]; then - mkdir -p ~/.nethack/save - for i in logfile perm record; do - [ ! -e ~/.nethack/\$i ] && touch ~/.nethack/\$i - done - fi + #! ${stdenv.shell} -e + + if [ ! -d ${userDir} ]; then + mkdir -p ${userDir} + cp -r $out/games/lib/nethackuserdir/* ${userDir} + chmod -R +w ${userDir} + fi - cd ~/.nethack + RUNDIR=\$(mktemp -td nethack.\$USER.XXXXX) - cleanup() { - for i in $out/games/lib/nethackdir/*; do - rm -rf \$(basename \$i) - done - } - trap cleanup EXIT + cleanup() { + rm -rf \$RUNDIR + } + trap cleanup EXIT - for i in $out/games/lib/nethackdir/*; do - ln -s \$i \$(basename \$i) - done - $out/games/nethack + 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 EOF chmod +x $out/bin/nethack ''; - makeFlags = [ "PREFIX=$(out)" ]; - meta = with stdenv.lib; { description = "Rogue-like game"; homepage = "http://nethack.org/"; |