mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-01 23:22:37 +00:00
nethack: 3.4.3 -> 3.6.0
I think a decade has passed ^_^
This commit is contained in:
parent
3b020106f8
commit
459a5c5803
@ -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 )
|
||||
makeFlags = [ "PREFIX=$(out)" ];
|
||||
|
||||
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 '/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
|
||||
|
||||
sed -re 's@^(CH...).*@\1 = true@' -i Makefile
|
||||
|
||||
sed -e '/^ *cd /d' -i sys/unix/nethack.sh
|
||||
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/";
|
||||
|
Loading…
Reference in New Issue
Block a user