From e074cce0cc53f0bd02f39671a514a3d30a537098 Mon Sep 17 00:00:00 2001 From: George Huebner Date: Sat, 2 May 2026 20:35:27 -0500 Subject: [PATCH 1/5] nethack: 3.6.7 -> 5.0.0 Co-authored-by: Gleb Smirnov --- .../ne/nethack/function-parameters.patch | 86 ---------- pkgs/by-name/ne/nethack/package.nix | 147 ++++++++---------- 2 files changed, 64 insertions(+), 169 deletions(-) delete mode 100644 pkgs/by-name/ne/nethack/function-parameters.patch 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; }; }) From 1ac185bf1bade4202a89ca14fcb62434e133d72f Mon Sep 17 00:00:00 2001 From: Palmer Cox Date: Thu, 14 May 2026 02:59:18 +0000 Subject: [PATCH 2/5] nethack: Convert the preBuild hook into a postUnpack hook I think this makes sense in that unpacking lua is part of the process of unpacking the source code. Also, it will be handy in a future commit since this means that we can use the patch phase in order to patch lua code for cross-compilation. --- pkgs/by-name/ne/nethack/package.nix | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/pkgs/by-name/ne/nethack/package.nix b/pkgs/by-name/ne/nethack/package.nix index e91bcc0c708c..11a26a67f6b1 100644 --- a/pkgs/by-name/ne/nethack/package.nix +++ b/pkgs/by-name/ne/nethack/package.nix @@ -52,6 +52,18 @@ stdenv.mkDerivation (finalAttrs: { sha256 = "sha256-KVm3iGqsdhhbkK6gyfgNFDQ/YE3grpaz3Sp2D3qzvek="; }; + 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 ] @@ -136,18 +148,6 @@ stdenv.mkDerivation (finalAttrs: { 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; From 052b7cc9adb0b0d1107e99a2812ff7d2922d375f Mon Sep 17 00:00:00 2001 From: Palmer Cox Date: Fri, 8 May 2026 03:55:11 +0000 Subject: [PATCH 3/5] nethack: Support cross compilation Major caveat: x11 and qt don't work. The main idea is to update the Makefiles with references to the correct toolchain by replacing direct executable names with references to the appropriate environment variables. We also update the makefiles to use tools from the buildPlatform's version of Nethack. As part of this, we have to final the install phase to install these as part of native builds. Finally, we fix an issue with the wrapper script where it would use the build platform's version of bash as opposed to the host platforms. --- pkgs/by-name/ne/nethack/package.nix | 36 ++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/pkgs/by-name/ne/nethack/package.nix b/pkgs/by-name/ne/nethack/package.nix index 11a26a67f6b1..43f3b46dca9f 100644 --- a/pkgs/by-name/ne/nethack/package.nix +++ b/pkgs/by-name/ne/nethack/package.nix @@ -7,6 +7,8 @@ ncurses, gzip, less, + bash, + buildPackages, x11Mode ? false, qtMode ? false, libxaw, @@ -140,6 +142,30 @@ stdenv.mkDerivation (finalAttrs: { sed -e '/define CHDIR/d' \ -e '/define ENHANCED_SYMBOLS/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 (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. + '' + 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 + '' + } ''; configurePhase = '' @@ -163,7 +189,7 @@ stdenv.mkDerivation (finalAttrs: { mkdir -p $out/bin cat <$out/bin/nethack - #! ${stdenv.shell} -e + #! ${lib.getExe bash} -e PATH=${binPath}:\$PATH if [ ! -d ${userDir} ]; then @@ -194,8 +220,12 @@ stdenv.mkDerivation (finalAttrs: { fi EOF chmod +x $out/bin/nethack - install -Dm 555 util/makedefs -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 = lib.optionals (x11Mode || qtMode) [ From bbbb21dbe8b7abae42785cabd51b0387eed14d5a Mon Sep 17 00:00:00 2001 From: Palmer Cox Date: Thu, 14 May 2026 14:13:51 +0000 Subject: [PATCH 4/5] nethack: Only patch the QT settings if qtMode is enabled By doing this we reduce the closure size of the build environment when qtMode is disabled. --- pkgs/by-name/ne/nethack/package.nix | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/pkgs/by-name/ne/nethack/package.nix b/pkgs/by-name/ne/nethack/package.nix index 43f3b46dca9f..0ecec40a1144 100644 --- a/pkgs/by-name/ne/nethack/package.nix +++ b/pkgs/by-name/ne/nethack/package.nix @@ -119,8 +119,6 @@ stdenv.mkDerivation (finalAttrs: { -e 's,^CFLAGS=-g,CFLAGS=,' \ -e 's,/bin/gzip,${gzip}/bin/gzip,g' \ -e 's,^WINTTYLIB=.*,WINTTYLIB=-lncurses,' \ - -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 @@ -133,9 +131,6 @@ stdenv.mkDerivation (finalAttrs: { -e 's,^CFLAGS+=-DCRASHREPORT,#CFLAGS+=-DCRASHREPORT,' \ -e 's,^NHCFLAGS+=-DGREPPATH,#NHCFLAGS+=-DGREPPATH,' \ -e 's,/usr/bin/true,${coreutils}/bin/true,g' \ - -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 @@ -149,6 +144,19 @@ stdenv.mkDerivation (finalAttrs: { sed \ -e 's,AR =.*,AR := $(AR),' \ -i sys/unix/Makefile.src + ${lib.optionalString qtMode + '' + sed \ + -e 's,^QTDIR *=.*,QTDIR=${qt5.qtbase.dev},' \ + -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 (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 From ca3b87d4f4773ccb1e7cb82d3a386988ec12a893 Mon Sep 17 00:00:00 2001 From: Jeremy O'Brien Date: Sun, 7 Jun 2026 15:16:11 -0400 Subject: [PATCH 5/5] nethack: update X11 font handling and binary names 1. We can keep ENHANCED_SYMBOLS enabled if we make the 2 fonts that nethack-x11 wants available to it. 2. Currently this outputs all three nethack variants as bin/nethack instead of bin/nethack-x11 and bin/nethack-qt which prevents us from installing multiple variants at the same time (the old package maintained this split). --- pkgs/by-name/ne/nethack/package.nix | 45 +++++++++++++++++++++-------- 1 file changed, 33 insertions(+), 12 deletions(-) diff --git a/pkgs/by-name/ne/nethack/package.nix b/pkgs/by-name/ne/nethack/package.nix index 0ecec40a1144..37e5507a37d0 100644 --- a/pkgs/by-name/ne/nethack/package.nix +++ b/pkgs/by-name/ne/nethack/package.nix @@ -16,6 +16,9 @@ libxpm, bdftopcf, mkfontdir, + xset, + font-misc-misc, + font-adobe-75dpi, pkg-config, qt5, copyDesktopItems, @@ -35,6 +38,16 @@ let coreutils 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 stdenv.mkDerivation (finalAttrs: { @@ -135,7 +148,6 @@ stdenv.mkDerivation (finalAttrs: { -DCOMPRESS_EXTENSION=\\".gz\\",' \ -i sys/unix/hints/macOS.500 sed -e '/define CHDIR/d' \ - -e '/define ENHANCED_SYMBOLS/d' \ -i include/config.h sed \ -e 's,AR=.*,AR := $(AR) rcu,' \ @@ -144,8 +156,7 @@ stdenv.mkDerivation (finalAttrs: { sed \ -e 's,AR =.*,AR := $(AR),' \ -i sys/unix/Makefile.src - ${lib.optionalString qtMode - '' + ${lib.optionalString qtMode '' sed \ -e 's,^QTDIR *=.*,QTDIR=${qt5.qtbase.dev},' \ -e 's,PKG_CONFIG_PATH=$(QTDIR)/lib/pkgconfig,,' \ @@ -155,8 +166,7 @@ stdenv.mkDerivation (finalAttrs: { QTDIR=${qt5.qtbase.dev},' \ -e 's,PKG_CONFIG_PATH=$(QTDIR)/lib/pkgconfig,,' \ -i sys/unix/hints/macOS.500 - '' - } + ''} ${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 @@ -209,10 +219,15 @@ stdenv.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) @@ -228,12 +243,12 @@ stdenv.mkDerivation (finalAttrs: { fi EOF chmod +x $out/bin/nethack - ${lib.optionalString (!x11Mode && !qtMode && (stdenv.buildPlatform == stdenv.hostPlatform)) - '' + ${lib.optionalString x11Mode "mv $out/bin/nethack $out/bin/nethack-x11"} + ${lib.optionalString qtMode "mv $out/bin/nethack $out/bin/nethack-qt"} + ${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 = lib.optionals (x11Mode || qtMode) [ @@ -262,6 +277,12 @@ stdenv.mkDerivation (finalAttrs: { license = lib.licenses.ngpl; platforms = lib.platforms.unix; maintainers = with lib.maintainers; [ olduser101 ]; - mainProgram = "nethack"; + mainProgram = + if x11Mode then + "nethack-x11" + else if qtMode then + "nethack-qt" + else + "nethack"; }; })