summary refs log tree commit diff
path: root/pkgs
diff options
context:
space:
mode:
authorNikolay Amiantov <ab@fmap.me>2015-12-08 17:45:44 +0300
committerNikolay Amiantov <ab@fmap.me>2015-12-08 17:52:09 +0300
commit459a5c5803206070a7256644da25526043c01327 (patch)
treee94634d0d3f28cb87f14b505e5fc315d04a18e45 /pkgs
parent3b020106f87102330de8d2b805c34556602fb341 (diff)
downloadnixpkgs-459a5c5803206070a7256644da25526043c01327.tar
nixpkgs-459a5c5803206070a7256644da25526043c01327.tar.gz
nixpkgs-459a5c5803206070a7256644da25526043c01327.tar.bz2
nixpkgs-459a5c5803206070a7256644da25526043c01327.tar.lz
nixpkgs-459a5c5803206070a7256644da25526043c01327.tar.xz
nixpkgs-459a5c5803206070a7256644da25526043c01327.tar.zst
nixpkgs-459a5c5803206070a7256644da25526043c01327.zip
nethack: 3.4.3 -> 3.6.0
I think a decade has passed ^_^
Diffstat (limited to 'pkgs')
-rw-r--r--pkgs/games/nethack/default.nix78
1 files changed, 46 insertions, 32 deletions
diff --git a/pkgs/games/nethack/default.nix b/pkgs/games/nethack/default.nix
index e5057c27e99..d3a510e2952 100644
--- a/pkgs/games/nethack/default.nix
+++ b/pkgs/games/nethack/default.nix
@@ -1,60 +1,76 @@
-{ 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 = "~/.local/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
+      if [ ! -d ${userDir} ]; then
+        mkdir -p ${userDir}
+        cp -r $out/games/lib/nethackuserdir/* ${userDir}
+        chmod -R +w ${userDir}
       fi
 
-      cd ~/.nethack
+      RUNDIR=$(mktemp -d nethack)
 
       cleanup() {
-        for i in $out/games/lib/nethackdir/*; do
-          rm -rf \$(basename \$i)
-        done
+        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
@@ -63,8 +79,6 @@ stdenv.mkDerivation rec {
     chmod +x $out/bin/nethack
   '';
 
-  makeFlags = [ "PREFIX=$(out)" ];
-
   meta = with stdenv.lib; {
     description = "Rogue-like game";
     homepage = "http://nethack.org/";