2021-01-11 08:54:33 +01:00
|
|
|
{ lib, stdenv, fetchFromGitHub, fetchpatch, util-linux, ncurses, flex, bison }:
|
2015-06-29 13:19:23 +02:00
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
2019-08-15 14:41:18 +02:00
|
|
|
pname = "unnethack";
|
2020-09-15 05:48:49 +02:00
|
|
|
version = "5.3.2";
|
2015-06-29 13:19:23 +02:00
|
|
|
|
2020-09-15 05:48:49 +02:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
name = "UnNetHack";
|
|
|
|
owner = "UnNetHack";
|
|
|
|
repo = "UnNetHack";
|
|
|
|
rev = version;
|
|
|
|
sha256 = "1rg0mqyplgn3dfh3wz09a600qxk7aidqw4d84kyiincljvhyb7ps";
|
2015-06-29 13:19:23 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
buildInputs = [ ncurses ];
|
|
|
|
|
2020-11-24 16:29:28 +01:00
|
|
|
nativeBuildInputs = [ util-linux flex bison ];
|
2015-06-29 13:19:23 +02:00
|
|
|
|
|
|
|
configureFlags = [ "--enable-curses-graphics"
|
|
|
|
"--disable-tty-graphics"
|
|
|
|
"--with-owner=no"
|
|
|
|
"--with-group=no"
|
|
|
|
"--with-gamesdir=/tmp/unnethack"
|
|
|
|
];
|
|
|
|
|
2017-06-16 14:24:39 +02:00
|
|
|
makeFlags = [ "GAMEPERM=744" ];
|
2020-09-15 05:48:49 +02:00
|
|
|
patches = [
|
|
|
|
# fix regression with bison, merged in master
|
|
|
|
(fetchpatch {
|
|
|
|
name = "fix-bison.patch";
|
|
|
|
url = "https://github.com/UnNetHack/UnNetHack/commit/04f0a3a850a94eb8837ddcef31303968240d1c31.patch";
|
|
|
|
sha256 = "1zblbwqqz9nx16k6n31wi2hdvz775lvzmkjblmrx18nbm4ylj0n9";
|
|
|
|
})
|
|
|
|
];
|
2017-06-16 14:24:39 +02:00
|
|
|
|
unnethack: disable `fortify3` to avoid startup crash
Without the change `unnethack` startup crashes as:
(gdb) bt
#0 __pthread_kill_implementation (threadid=<optimized out>, signo=signo@entry=6, no_tid=no_tid@entry=0) at pthread_kill.c:44
#1 0x00007f734250c0e3 in __pthread_kill_internal (signo=6, threadid=<optimized out>) at pthread_kill.c:78
#2 0x00007f73424bce06 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
#3 0x00007f73424a58f5 in __GI_abort () at abort.c:79
#4 0x00007f73424a67a1 in __libc_message (fmt=fmt@entry=0x7f734261e2f8 "*** %s ***: terminated\n") at ../sysdeps/posix/libc_fatal.c:150
#5 0x00007f734259b1d9 in __GI___fortify_fail (msg=msg@entry=0x7f734261e2df "buffer overflow detected") at fortify_fail.c:24
#6 0x00007f734259ab94 in __GI___chk_fail () at chk_fail.c:28
#7 0x00000000005b2ac5 in strcpy (__src=0x7ffe68838b00 "Shall I pick a character's race, role, gender and alignment for you? [YNTQ] (y)",
__dest=0x7ffe68838990 "\001") at /nix/store/B0S2LKF593R3585038WS4JD3LYLF2WDX-glibc-2.38-44-dev/include/bits/string_fortified.h:79
#8 curses_break_str (str=str@entry=0x7ffe68838b00 "Shall I pick a character's race, role, gender and alignment for you? [YNTQ] (y)", width=width@entry=163,
line_num=line_num@entry=1) at ../win/curses/cursmisc.c:275
#9 0x00000000005b3f51 in curses_character_input_dialog (prompt=prompt@entry=0x7ffe68838cf0 "Shall I pick a character's race, role, gender and alignment for you?",
choices=choices@entry=0x7ffe68838d70 "YNTQ", def=def@entry=121) at ../win/curses/cursdial.c:211
#10 0x00000000005b9ca0 in curses_choose_character () at ../win/curses/cursinit.c:556
#11 0x0000000000404eb1 in main (argc=<optimized out>, argv=<optimized out>) at ./../sys/unix/unixmain.c:309
which corresponds to `gcc` warning:
../win/curses/cursmisc.c: In function 'curses_break_str':
../win/curses/cursmisc.c:275:5: warning: '__builtin___strcpy_chk' writing one too many bytes into a region of a size that depends on 'strlen' [-Wstringop-overflow=]
275 | strcpy(substr, str);
| ^
I did not find a single small upstream change that fixes it. Let's
disable `fortify3` until next release.
Closes: https://github.com/NixOS/nixpkgs/issues/292113
2024-02-28 23:33:39 +01:00
|
|
|
# Fails at startup due to off-by-one:
|
|
|
|
# https://github.com/NixOS/nixpkgs/issues/292113#issuecomment-1969989058
|
|
|
|
# TODO: drop it once 6.x branch releases.
|
|
|
|
hardeningDisable = [ "fortify3" ];
|
|
|
|
|
2023-03-10 00:12:31 +01:00
|
|
|
# Fails the build occasionally due to missing buid depends:
|
|
|
|
# ./../sys/unix/unixmain.c:9:10: fatal error: date.h: No such file or directory
|
|
|
|
# TODO: remove once upstream issue is fixed:
|
|
|
|
# https://github.com/UnNetHack/UnNetHack/issues/56
|
|
|
|
enableParallelBuilding = false;
|
2019-06-03 17:42:59 +02:00
|
|
|
|
2015-06-29 13:19:23 +02:00
|
|
|
postInstall = ''
|
|
|
|
cp -r /tmp/unnethack $out/share/unnethack/profile
|
|
|
|
mv $out/bin/unnethack $out/bin/.wrapped_unnethack
|
|
|
|
cat <<EOF >$out/bin/unnethack
|
|
|
|
#! ${stdenv.shell} -e
|
|
|
|
if [ ! -d ~/.unnethack ]; then
|
|
|
|
mkdir -p ~/.unnethack
|
|
|
|
cp -r $out/share/unnethack/profile/* ~/.unnethack
|
|
|
|
chmod -R +w ~/.unnethack
|
|
|
|
fi
|
|
|
|
|
|
|
|
ln -s ~/.unnethack /tmp/unnethack
|
|
|
|
|
|
|
|
cleanup() {
|
|
|
|
rm -rf /tmp/unnethack
|
|
|
|
}
|
|
|
|
trap cleanup EXIT
|
|
|
|
|
|
|
|
$out/bin/.wrapped_unnethack
|
|
|
|
EOF
|
|
|
|
chmod +x $out/bin/unnethack
|
|
|
|
'';
|
|
|
|
|
2021-01-11 08:54:33 +01:00
|
|
|
meta = with lib; {
|
2015-06-29 13:19:23 +02:00
|
|
|
description = "Fork of NetHack";
|
2024-03-19 03:14:51 +01:00
|
|
|
mainProgram = "unnethack";
|
2020-04-01 03:11:51 +02:00
|
|
|
homepage = "https://unnethack.wordpress.com/";
|
2015-06-29 13:19:23 +02:00
|
|
|
license = "nethack";
|
|
|
|
platforms = platforms.all;
|
|
|
|
maintainers = with maintainers; [ abbradar ];
|
2020-09-15 05:48:49 +02:00
|
|
|
};
|
2015-06-29 13:19:23 +02:00
|
|
|
}
|