nethack: fix darwin support

This commit is contained in:
Matthew Bauer 2016-02-28 21:04:23 -06:00
parent a133ef9a0c
commit 818f2cd19f

View File

@ -6,6 +6,7 @@ let
else abort "Unknown platform for NetHack";
unixHint =
if stdenv.isLinux then "linux"
else if stdenv.isDarwin then "macosx10.10"
# We probably want something different for Darwin
else "unix";
userDir = "~/.config/nethack";
@ -24,25 +25,30 @@ in stdenv.mkDerivation {
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 CHDIR/d' -i include/config.h
patchPhase = ''
sed -e '/^ *cd /d' -i sys/unix/nethack.sh
sed \
-e 's/^YACC *=.*/YACC = bison -y/' \
-e 's/^LEX *=.*/LEX = flex/' \
-i util/Makefile
-i sys/unix/Makefile.utl
sed \
-e 's,/bin/gzip,${gzip}/bin/gzip,g' \
-e 's,^WINTTYLIB=.*,WINTTYLIB=-lncurses,' \
-i sys/unix/hints/linux
sed \
-e 's,^CC=.*$,CC=cc,' \
-e 's,^HACKDIR=.*$,HACKDIR=\$(PREFIX)/games/lib/\$(GAME)dir,' \
-e 's,^SHELLDIR=.*$,SHELLDIR=\$(PREFIX)/games,' \
-i sys/unix/hints/macosx10.10
sed -e '/define CHDIR/d' -i include/config.h
'';
configurePhase = ''
cd sys/${platform}
${lib.optionalString (platform == "unix") ''
sh setup.sh hints/${unixHint}
''}
cd ../..
'';
postInstall = ''
@ -61,7 +67,7 @@ in stdenv.mkDerivation {
chmod -R +w ${userDir}
fi
RUNDIR=\$(mktemp -td nethack.\$USER.XXXXX)
RUNDIR=\$(mktemp -d)
cleanup() {
rm -rf \$RUNDIR