diff --git a/pkgs/by-name/ne/nethack/function-parameters.patch b/pkgs/by-name/ne/nethack/function-parameters.patch deleted file mode 100644 index 7060916d0392..000000000000 --- a/pkgs/by-name/ne/nethack/function-parameters.patch +++ /dev/null @@ -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" diff --git a/pkgs/by-name/ne/nethack/package.nix b/pkgs/by-name/ne/nethack/package.nix index 6a03396657a6..e91bcc0c708c 100644 --- a/pkgs/by-name/ne/nethack/package.nix +++ b/pkgs/by-name/ne/nethack/package.nix @@ -3,13 +3,10 @@ lib, fetchurl, coreutils, + groff, ncurses, gzip, - gccStdenv, - flex, - bison, less, - buildPackages, x11Mode ? false, qtMode ? false, libxaw, @@ -24,23 +21,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"; @@ -48,10 +33,10 @@ let coreutils less ]; - in -stdenvUsed.mkDerivation (finalAttrs: { - version = "3.6.7"; + +stdenv.mkDerivation (finalAttrs: { + version = "5.0.0"; pname = if x11Mode then "nethack-x11" @@ -64,14 +49,9 @@ 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 - ]; - buildInputs = [ ncurses ] @@ -87,16 +67,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,66 +83,71 @@ 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,^QTDIR *=.*,QTDIR=${qt5.qtbase.dev},' \ + -e 's,PKG_CONFIG_PATH=$(QTDIR)/lib/pkgconfig,,' \ + -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 - ${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 - ''} - ${lib.optionalString (stdenvUsed.buildPlatform != stdenvUsed.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' \ - -i sys/unix/Makefile.* - '' - } - 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 + -e 's,^endif # QTDIR,endif # QTDIR \ + QTDIR=${qt5.qtbase.dev},' \ + -e 's,PKG_CONFIG_PATH=$(QTDIR)/lib/pkgconfig,,' \ + -e 's,NHCFLAGS+=-DCOMPRESS[^ ]*,NHCFLAGS+=-DCOMPRESS=\\"${gzip}/bin/gzip\\" \\\ + -DCOMPRESS_EXTENSION=\\".gz\\",' \ + -i sys/unix/hints/macOS.500 + sed -e '/define CHDIR/d' \ + -e '/define ENHANCED_SYMBOLS/d' \ + -i include/config.h ''; configurePhase = '' - pushd sys/${platform} - ${lib.optionalString (platform == "unix") '' - sh setup.sh hints/${unixHint} - ''} + pushd sys/unix + sh setup.sh hints/${hint} popd ''; + preBuild = + let + lua548 = fetchurl { + url = "https://www.lua.org/ftp/lua-5.4.8.tar.gz"; + hash = "sha256-TxjdrhVOeT5G7qtyfFnvHAwMK3ROe5QhlxDXb1MGKa4="; + }; + in + '' + mkdir -p lib + tar zxf ${lua548} -C lib + ''; + # https://github.com/NixOS/nixpkgs/issues/294751 enableParallelBuilding = false; @@ -179,7 +163,7 @@ stdenvUsed.mkDerivation (finalAttrs: { mkdir -p $out/bin cat <$out/bin/nethack - #! ${stdenvUsed.shell} -e + #! ${stdenv.shell} -e PATH=${binPath}:\$PATH if [ ! -d ${userDir} ]; then @@ -210,13 +194,11 @@ stdenvUsed.mkDerivation (finalAttrs: { fi EOF 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/ + install -Dm 555 util/makedefs -t $out/libexec/nethack/ ${lib.optionalString (!(x11Mode || qtMode)) "install -Dm 555 util/dlb -t $out/libexec/nethack/"} ''; - desktopItems = [ + desktopItems = lib.optionals (x11Mode || qtMode) [ (makeDesktopItem { name = "NetHack"; exec = @@ -240,9 +222,8 @@ 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; }; })