nethack: 3.6.7 -> 5.0.0 (#529234)

This commit is contained in:
Alexis Hildebrandt
2026-06-11 06:10:52 +00:00
committed by GitHub
2 changed files with 111 additions and 157 deletions
@@ -1,86 +0,0 @@
diff --git a/include/system.h b/include/system.h
index a2cb51f..9f40fdd 100644
--- a/include/system.h
+++ b/include/system.h
@@ -60,17 +60,17 @@ typedef long off_t;
#endif
#ifndef SIG_RET_TYPE
#if defined(NHSTDC) || defined(POSIX_TYPES) || defined(OS2) || defined(__DECC)
-#define SIG_RET_TYPE void (*)()
+#define SIG_RET_TYPE void (*)(int)
#endif
#endif
#ifndef SIG_RET_TYPE
#if defined(ULTRIX) || defined(SUNOS4) || defined(SVR3) || defined(SVR4)
/* SVR3 is defined automatically by some systems */
-#define SIG_RET_TYPE void (*)()
+#define SIG_RET_TYPE void (*)(int)
#endif
#endif
#ifndef SIG_RET_TYPE /* BSD, SIII, SVR2 and earlier, Sun3.5 and earlier */
-#define SIG_RET_TYPE int (*)()
+#define SIG_RET_TYPE int (*)(int)
#endif
#if !defined(__cplusplus) && !defined(__GO32__)
@@ -96,7 +96,7 @@ E long NDECL(lrand48);
E void FDECL(srand48, (long));
#else
E long lrand48();
-E void srand48();
+E void srand48(long);
#endif /* MACOSX */
#endif /* BSD || ULTRIX || RANDOM */
@@ -352,10 +352,10 @@ E char *FDECL(memset, (char *, int, int));
#endif /* MICRO */
#if defined(BSD) && defined(ultrix) /* i.e., old versions of Ultrix */
-E void sleep();
+E void sleep(unsigned);
#endif
#if defined(ULTRIX) || defined(SYSV)
-E unsigned sleep();
+E unsigned sleep(unsigned);
#endif
#if defined(HPUX)
E unsigned int FDECL(sleep, (unsigned int));
@@ -519,7 +519,7 @@ E char *FDECL(tgoto, (const char *, int, int));
#else
#if !(defined(HPUX) && defined(_POSIX_SOURCE))
E int FDECL(tgetent, (char *, const char *));
-E void FDECL(tputs, (const char *, int, int (*)()));
+E void FDECL(tputs, (const char *, int, int (*)(int)));
#endif
E int FDECL(tgetnum, (const char *));
E int FDECL(tgetflag, (const char *));
diff --git a/include/winX.h b/include/winX.h
index a1a5605..1d6b84b 100644
--- a/include/winX.h
+++ b/include/winX.h
@@ -279,7 +279,7 @@ typedef struct {
} AppResources;
E AppResources appResources;
-E void (*input_func)();
+E void (*input_func)(Widget, XEvent *, String *, Cardinal *);
extern struct window_procs X11_procs;
diff --git a/include/xwindow.h b/include/xwindow.h
index 8b9cfa0..8307c25 100644
--- a/include/xwindow.h
+++ b/include/xwindow.h
@@ -76,8 +76,10 @@
#define XtNexposeCallback "exposeCallback"
#define XtNresizeCallback "resizeCallback"
-extern XFontStruct *WindowFontStruct(/* Widget */);
-extern Font WindowFont(/* Widget */);
+struct Widget;
+
+extern XFontStruct *WindowFontStruct(Widget);
+extern Font WindowFont(Widget);
#define XtCWindowResource "WindowResource"
#define XtCRows "Rows"
+111 -71
View File
@@ -3,12 +3,11 @@
lib,
fetchurl,
coreutils,
groff,
ncurses,
gzip,
gccStdenv,
flex,
bison,
less,
bash,
buildPackages,
x11Mode ? false,
qtMode ? false,
@@ -17,6 +16,9 @@
libxpm,
bdftopcf,
mkfontdir,
xset,
font-misc-misc,
font-adobe-75dpi,
pkg-config,
qt5,
copyDesktopItems,
@@ -24,23 +26,11 @@
}:
let
stdenvUsed = if qtMode then gccStdenv else stdenv;
platform =
if stdenvUsed.hostPlatform.isUnix then
"unix"
else
throw "Unknown platform for NetHack: ${stdenvUsed.hostPlatform.system}";
unixHint =
if x11Mode then
"linux-x11"
else if qtMode then
"linux-qt4"
else if stdenvUsed.hostPlatform.isLinux then
"linux"
else if stdenvUsed.hostPlatform.isDarwin then
"macosx10.14"
# We probably want something different for Darwin
hint =
if stdenv.hostPlatform.isLinux then
"linux.500"
else if stdenv.hostPlatform.isDarwin then
"macos.500"
else
"unix";
userDir = "~/.config/nethack";
@@ -49,9 +39,19 @@ let
less
];
# The X11 interface loads core X bitmap fonts by XLFD: the "fixed" font for
# the map and menus (the iso10646-1 variant is used for ENHANCED_SYMBOLS) and
# adobe "times" for the tombstone. NixOS's X server doesn't have these on its
# font path by default, so we make the launcher add them at startup, the same
# way upstream's nethack.sh does for its own bundled font.
x11FontPath = lib.concatStringsSep "," [
"${font-misc-misc}/share/fonts/X11/misc"
"${font-adobe-75dpi}/share/fonts/X11/75dpi"
];
in
stdenvUsed.mkDerivation (finalAttrs: {
version = "3.6.7";
stdenv.mkDerivation (finalAttrs: {
version = "5.0.0";
pname =
if x11Mode then
"nethack-x11"
@@ -64,13 +64,20 @@ stdenvUsed.mkDerivation (finalAttrs: {
url = "https://nethack.org/download/${finalAttrs.version}/nethack-${
lib.replaceStrings [ "." ] [ "" ] finalAttrs.version
}-src.tgz";
hash = "sha256-mM9n323r+WaKYXRaqEwJvKs2Ll0z9blE7FFV1E0qrLI=";
sha256 = "sha256-KVm3iGqsdhhbkK6gyfgNFDQ/YE3grpaz3Sp2D3qzvek=";
};
patches = [
# Newer GCC rejects function declarations without explicit parameters.
./function-parameters.patch
];
postUnpack =
let
lua548 = fetchurl {
url = "https://www.lua.org/ftp/lua-5.4.8.tar.gz";
hash = "sha256-TxjdrhVOeT5G7qtyfFnvHAwMK3ROe5QhlxDXb1MGKa4=";
};
in
''
mkdir -p NetHack-${finalAttrs.version}/lib
tar zxf ${lua548} -C NetHack-${finalAttrs.version}/lib
'';
buildInputs = [
ncurses
@@ -87,16 +94,15 @@ stdenvUsed.mkDerivation (finalAttrs: {
];
nativeBuildInputs = [
flex
bison
copyDesktopItems
groff
pkg-config
]
++ lib.optionals x11Mode [
mkfontdir
bdftopcf
]
++ lib.optionals qtMode [
pkg-config
mkfontdir
qt5.qtbase.dev
qt5.qtmultimedia.dev
@@ -104,63 +110,85 @@ stdenvUsed.mkDerivation (finalAttrs: {
bdftopcf
];
makeFlags = [ "PREFIX=$(out)" ];
makeFlags = [
"PREFIX=$(out)"
"WANT_WIN_TTY=1"
"WANT_WIN_CURSES=1"
"WANT_DEFAULT=curses"
]
++ lib.optionals x11Mode [
"WANT_WIN_X11=1"
"WANT_DEFAULT=X11"
]
++ lib.optionals qtMode [
"WANT_WIN_QT=1"
"WANT_DEFAULT=Qt"
];
postPatch = ''
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
sed \
-e 's,^WINQT4LIB =.*,WINQT4LIB = `pkg-config Qt5Gui --libs` \\\
`pkg-config Qt5Widgets --libs` \\\
`pkg-config Qt5Multimedia --libs`,' \
-i sys/unix/Makefile.src
sed -e '/rm -f $(MAKEDEFS)/d' -i sys/unix/Makefile.src
sed \
-e 's,^CFLAGS=-g,CFLAGS=,' \
-e 's,/bin/gzip,${gzip}/bin/gzip,g' \
-e 's,^WINTTYLIB=.*,WINTTYLIB=-lncurses,' \
-i sys/unix/hints/linux
-e 's,NHCFLAGS+=-DCOMPRESS[^ ]*,NHCFLAGS+=-DCOMPRESS=\\"${gzip}/bin/gzip\\" \\\
-DCOMPRESS_EXTENSION=\\".gz\\",' \
-i sys/unix/hints/linux.500
sed \
-E 's/^(GDBPATH|GREPPATH)/#\1/' \
-i sys/unix/sysconf
sed \
-e 's,^#WANT_WIN_CURSES=1$,WANT_WIN_CURSES=1,' \
-e 's,^CC=.*$,CC=${stdenvUsed.cc.targetPrefix}cc,' \
-e 's,^HACKDIR=.*$,HACKDIR=\$(PREFIX)/games/lib/\$(GAME)dir,' \
-e 's,^SHELLDIR=.*$,SHELLDIR=\$(PREFIX)/games,' \
-e 's,^CFLAGS=-g,CFLAGS=,' \
-e 's,^CFLAGS+=-DCRASHREPORT,#CFLAGS+=-DCRASHREPORT,' \
-e 's,^NHCFLAGS+=-DGREPPATH,#NHCFLAGS+=-DGREPPATH,' \
-e 's,/usr/bin/true,${coreutils}/bin/true,g' \
-i sys/unix/hints/macosx10.14
sed -e '/define CHDIR/d' -i include/config.h
-e 's,NHCFLAGS+=-DCOMPRESS[^ ]*,NHCFLAGS+=-DCOMPRESS=\\"${gzip}/bin/gzip\\" \\\
-DCOMPRESS_EXTENSION=\\".gz\\",' \
-i sys/unix/hints/macOS.500
sed -e '/define CHDIR/d' \
-i include/config.h
sed \
-e 's,AR=.*,AR := $(AR) rcu,' \
-e 's,RANLIB=.*,RANLIB := $(RANLIB),' \
-i lib/lua-5.4.8/src/Makefile
sed \
-e 's,AR =.*,AR := $(AR),' \
-i sys/unix/Makefile.src
${lib.optionalString qtMode ''
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\\",' \
-e 's,moc-qt4,moc,' \
-i sys/unix/hints/linux-qt4
-e 's,PKG_CONFIG_PATH=$(QTDIR)/lib/pkgconfig,,' \
-i sys/unix/hints/linux.500
sed \
-e 's,^endif # QTDIR,endif # QTDIR \
QTDIR=${qt5.qtbase.dev},' \
-e 's,PKG_CONFIG_PATH=$(QTDIR)/lib/pkgconfig,,' \
-i sys/unix/hints/macOS.500
''}
${lib.optionalString (stdenvUsed.buildPlatform != stdenvUsed.hostPlatform)
${lib.optionalString (stdenv.buildPlatform != stdenv.hostPlatform)
# If we're cross-compiling, replace the paths to the data generation tools
# with the ones from the build platform's nethack package, since we can't
# run the ones we've built here.
''
${buildPackages.perl}/bin/perl -p \
-e 's,[a-z./]+/(makedefs|dgn_comp|lev_comp|dlb)(?!\.),${buildPackages.nethack}/libexec/nethack/\1,g' \
sed \
-e 's, ../util/makedefs,,' \
-e 's,\t../util/makedefs,\t${buildPackages.nethack}/libexec/nethack/makedefs,' \
-e 's,\t../util/dlb,\t${buildPackages.nethack}/libexec/nethack/dlb,' \
-e 's,../util/dlb cf nhdat,${buildPackages.nethack}/libexec/nethack/dlb cf nhdat,' \
-e 's,pkg-config,$(PKG_CONFIG),' \
-i sys/unix/Makefile.*
sed \
-e 's,pkg-config,$(PKG_CONFIG),' \
-i sys/unix/hints/linux.500
''
}
sed -i -e '/rm -f $(MAKEDEFS)/d' sys/unix/Makefile.src
# Fix building on darwin where otherwise __has_attribute fails with an empty parameter
sed -e 's/define __warn_unused_result__ .*/define __warn_unused_result__ __unused__/' -i include/tradstdc.h
sed -e 's/define warn_unused_result .*/define warn_unused_result __unused__/' -i include/tradstdc.h
'';
configurePhase = ''
pushd sys/${platform}
${lib.optionalString (platform == "unix") ''
sh setup.sh hints/${unixHint}
''}
pushd sys/unix
sh setup.sh hints/${hint}
popd
'';
@@ -179,7 +207,7 @@ stdenvUsed.mkDerivation (finalAttrs: {
mkdir -p $out/bin
cat <<EOF >$out/bin/nethack
#! ${stdenvUsed.shell} -e
#! ${lib.getExe bash} -e
PATH=${binPath}:\$PATH
if [ ! -d ${userDir} ]; then
@@ -191,10 +219,15 @@ stdenvUsed.mkDerivation (finalAttrs: {
RUNDIR=\$(mktemp -d)
cleanup() {
rm -rf \$RUNDIR
rm -rf \$RUNDIR${lib.optionalString x11Mode ''
${xset}/bin/xset -fp ${x11FontPath} >/dev/null 2>&1 || true''}
}
trap cleanup EXIT
${lib.optionalString x11Mode ''
${xset}/bin/xset +fp ${x11FontPath} >/dev/null 2>&1 || true
${xset}/bin/xset fp rehash >/dev/null 2>&1 || true
''}
cd \$RUNDIR
for i in ${userDir}/*; do
ln -s \$i \$(basename \$i)
@@ -212,11 +245,13 @@ stdenvUsed.mkDerivation (finalAttrs: {
chmod +x $out/bin/nethack
${lib.optionalString x11Mode "mv $out/bin/nethack $out/bin/nethack-x11"}
${lib.optionalString qtMode "mv $out/bin/nethack $out/bin/nethack-qt"}
install -Dm 555 util/{makedefs,dgn_comp,lev_comp} -t $out/libexec/nethack/
${lib.optionalString (!(x11Mode || qtMode)) "install -Dm 555 util/dlb -t $out/libexec/nethack/"}
${lib.optionalString (!x11Mode && !qtMode && (stdenv.buildPlatform == stdenv.hostPlatform)) ''
install -Dm 555 util/makedefs -t $out/libexec/nethack/
install -Dm 555 util/dlb -t $out/libexec/nethack/
''}
'';
desktopItems = [
desktopItems = lib.optionals (x11Mode || qtMode) [
(makeDesktopItem {
name = "NetHack";
exec =
@@ -240,9 +275,14 @@ stdenvUsed.mkDerivation (finalAttrs: {
description = "Rogue-like game";
homepage = "http://nethack.org/";
license = lib.licenses.ngpl;
platforms = if x11Mode then lib.platforms.linux else lib.platforms.unix;
platforms = lib.platforms.unix;
maintainers = with lib.maintainers; [ olduser101 ];
mainProgram = "nethack";
broken = if qtMode then stdenv.hostPlatform.isDarwin else false;
mainProgram =
if x11Mode then
"nethack-x11"
else if qtMode then
"nethack-qt"
else
"nethack";
};
})