2018-07-21 01:44:44 +01:00
|
|
|
{ stdenv, lib, fetchurl, coreutils, ncurses, gzip, flex, bison
|
2018-07-15 22:06:59 +01:00
|
|
|
, less, makeWrapper
|
2018-07-15 07:18:55 +01:00
|
|
|
, x11Mode ? false, qtMode ? false, libXaw, libXext, mkfontdir, pkgconfig, qt5
|
2018-06-29 13:21:56 +01:00
|
|
|
}:
|
2015-06-29 12:19:12 +01:00
|
|
|
|
2015-12-08 14:45:44 +00:00
|
|
|
let
|
|
|
|
platform =
|
2018-03-09 23:40:51 +00:00
|
|
|
if stdenv.hostPlatform.isUnix then "unix"
|
2018-08-20 20:11:29 +01:00
|
|
|
else throw "Unknown platform for NetHack: ${stdenv.hostPlatform.system}";
|
2015-12-08 14:45:44 +00:00
|
|
|
unixHint =
|
2018-06-29 13:21:56 +01:00
|
|
|
if x11Mode then "linux-x11"
|
2018-07-15 07:18:55 +01:00
|
|
|
else if qtMode then "linux-qt4"
|
2018-06-29 13:21:56 +01:00
|
|
|
else if stdenv.hostPlatform.isLinux then "linux"
|
2018-03-09 23:40:51 +00:00
|
|
|
else if stdenv.hostPlatform.isDarwin then "macosx10.10"
|
2015-12-08 14:45:44 +00:00
|
|
|
# We probably want something different for Darwin
|
|
|
|
else "unix";
|
2015-12-08 15:10:53 +00:00
|
|
|
userDir = "~/.config/nethack";
|
2017-04-06 14:27:36 +01:00
|
|
|
binPath = lib.makeBinPath [ coreutils less ];
|
2015-12-08 14:45:44 +00:00
|
|
|
|
2018-07-15 07:18:55 +01:00
|
|
|
in stdenv.mkDerivation rec {
|
|
|
|
version = "3.6.1";
|
|
|
|
name = if x11Mode then "nethack-x11-${version}"
|
|
|
|
else if qtMode then "nethack-qt-${version}"
|
|
|
|
else "nethack-${version}";
|
2015-06-29 12:19:12 +01:00
|
|
|
|
2009-05-12 05:27:10 +01:00
|
|
|
src = fetchurl {
|
2018-06-28 19:43:35 +01:00
|
|
|
url = "https://nethack.org/download/3.6.1/nethack-361-src.tgz";
|
2018-06-10 03:33:13 +01:00
|
|
|
sha256 = "1dha0ijvxhx7c9hr0452h93x81iiqsll8bc9msdnp7xdqcfbz32b";
|
2009-05-12 05:27:10 +01:00
|
|
|
};
|
|
|
|
|
2018-07-15 07:18:55 +01:00
|
|
|
buildInputs = [ ncurses ]
|
|
|
|
++ lib.optionals x11Mode [ libXaw libXext ]
|
|
|
|
++ lib.optionals qtMode [ gzip qt5.qtbase.bin qt5.qtmultimedia.bin ];
|
2015-06-29 12:19:12 +01:00
|
|
|
|
2018-07-15 07:18:55 +01:00
|
|
|
nativeBuildInputs = [ flex bison ]
|
|
|
|
++ lib.optionals x11Mode [ mkfontdir ]
|
|
|
|
++ lib.optionals qtMode [
|
|
|
|
pkgconfig mkfontdir qt5.qtbase.dev
|
2018-07-15 22:06:59 +01:00
|
|
|
qt5.qtmultimedia.dev makeWrapper
|
2018-07-15 07:18:55 +01:00
|
|
|
];
|
2009-05-12 05:27:10 +01:00
|
|
|
|
2015-12-08 14:45:44 +00:00
|
|
|
makeFlags = [ "PREFIX=$(out)" ];
|
2009-05-12 05:27:10 +01:00
|
|
|
|
2018-08-08 16:36:21 +01:00
|
|
|
postPatch = ''
|
2016-02-29 03:04:23 +00:00
|
|
|
sed -e '/^ *cd /d' -i sys/unix/nethack.sh
|
|
|
|
sed \
|
|
|
|
-e 's/^YACC *=.*/YACC = bison -y/' \
|
|
|
|
-e 's/^LEX *=.*/LEX = flex/' \
|
|
|
|
-i sys/unix/Makefile.utl
|
2018-07-15 07:18:55 +01:00
|
|
|
sed \
|
|
|
|
-e 's,^WINQT4LIB =.*,WINQT4LIB = `pkg-config Qt5Gui --libs` \\\
|
|
|
|
`pkg-config Qt5Widgets --libs` \\\
|
|
|
|
`pkg-config Qt5Multimedia --libs`,' \
|
|
|
|
-i sys/unix/Makefile.src
|
2016-02-29 03:04:23 +00:00
|
|
|
sed \
|
2018-08-08 16:36:21 +01:00
|
|
|
-e 's,^CFLAGS=-g,CFLAGS=,' \
|
2016-02-29 03:04:23 +00:00
|
|
|
-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,' \
|
2018-08-08 16:36:21 +01:00
|
|
|
-e 's,^CFLAGS=-g,CFLAGS=,' \
|
2016-02-29 03:04:23 +00:00
|
|
|
-i sys/unix/hints/macosx10.10
|
|
|
|
sed -e '/define CHDIR/d' -i include/config.h
|
2018-09-19 18:30:09 +01:00
|
|
|
${lib.optionalString qtMode ''
|
2018-07-15 07:18:55 +01:00
|
|
|
sed \
|
|
|
|
-e 's,^QTDIR *=.*,QTDIR=${qt5.qtbase.dev},' \
|
|
|
|
-e 's,CFLAGS.*QtGui.*,CFLAGS += `pkg-config Qt5Gui --cflags`,' \
|
|
|
|
-e 's,CFLAGS+=-DCOMPRESS.*,CFLAGS+=-DCOMPRESS=\\"${gzip}/bin/gzip\\" \\\
|
|
|
|
-DCOMPRESS_EXTENSION=\\".gz\\",' \
|
|
|
|
-i sys/unix/hints/linux-qt4
|
2018-09-19 18:30:09 +01:00
|
|
|
''}
|
2016-02-29 03:04:23 +00:00
|
|
|
'';
|
|
|
|
|
2015-12-08 14:45:44 +00:00
|
|
|
configurePhase = ''
|
2018-08-08 16:36:21 +01:00
|
|
|
pushd sys/${platform}
|
2015-12-08 14:45:44 +00:00
|
|
|
${lib.optionalString (platform == "unix") ''
|
|
|
|
sh setup.sh hints/${unixHint}
|
|
|
|
''}
|
2018-08-08 16:36:21 +01:00
|
|
|
popd
|
2015-06-29 12:19:12 +01:00
|
|
|
'';
|
|
|
|
|
|
|
|
postInstall = ''
|
2015-12-08 14:45:44 +00:00
|
|
|
mkdir -p $out/games/lib/nethackuserdir
|
2016-06-03 07:46:34 +01:00
|
|
|
for i in xlogfile 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 12:19:12 +01:00
|
|
|
done
|
|
|
|
|
2012-01-18 20:16:00 +00:00
|
|
|
mkdir -p $out/bin
|
2015-06-29 12:19:12 +01:00
|
|
|
cat <<EOF >$out/bin/nethack
|
2015-12-08 15:10:53 +00:00
|
|
|
#! ${stdenv.shell} -e
|
2017-04-06 14:27:36 +01:00
|
|
|
PATH=${binPath}:\$PATH
|
2015-06-29 12:19:12 +01: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 12:19:12 +01:00
|
|
|
|
2016-02-29 03:04:23 +00:00
|
|
|
RUNDIR=\$(mktemp -d)
|
2015-06-29 12:19:12 +01: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 12:19:12 +01:00
|
|
|
EOF
|
|
|
|
chmod +x $out/bin/nethack
|
2018-06-29 13:21:56 +01:00
|
|
|
${lib.optionalString x11Mode "mv $out/bin/nethack $out/bin/nethack-x11"}
|
2018-07-15 07:18:55 +01:00
|
|
|
${lib.optionalString qtMode "mv $out/bin/nethack $out/bin/nethack-qt"}
|
2015-06-29 12:19:12 +01:00
|
|
|
'';
|
|
|
|
|
2018-07-15 22:06:59 +01:00
|
|
|
postFixup = lib.optionalString qtMode ''
|
|
|
|
wrapProgram $out/bin/nethack-qt \
|
|
|
|
--prefix QT_PLUGIN_PATH : "${qt5.qtbase}/${qt5.qtbase.qtPluginPrefix}"
|
|
|
|
'';
|
|
|
|
|
2015-06-29 12:19:12 +01:00
|
|
|
meta = with stdenv.lib; {
|
|
|
|
description = "Rogue-like game";
|
2017-08-01 21:03:30 +01:00
|
|
|
homepage = http://nethack.org/;
|
2015-06-29 12:19:12 +01:00
|
|
|
license = "nethack";
|
2018-06-29 13:21:56 +01:00
|
|
|
platforms = if x11Mode then platforms.linux else platforms.unix;
|
2015-06-29 12:19:12 +01:00
|
|
|
maintainers = with maintainers; [ abbradar ];
|
2009-05-12 05:27:10 +01:00
|
|
|
};
|
|
|
|
}
|