Merge pull request #268619 from tweag/lib-descriptions
[NixPkgs.git] / pkgs / games / unnethack / default.nix
blobaf402a7de9359c77c973db15436150742328bf91
1 { lib, stdenv, fetchFromGitHub, fetchpatch, util-linux, ncurses, flex, bison }:
3 stdenv.mkDerivation rec {
4   pname = "unnethack";
5   version = "5.3.2";
7   src = fetchFromGitHub {
8     name = "UnNetHack";
9     owner = "UnNetHack";
10     repo = "UnNetHack";
11     rev = version;
12     sha256 = "1rg0mqyplgn3dfh3wz09a600qxk7aidqw4d84kyiincljvhyb7ps";
13   };
15   buildInputs = [ ncurses ];
17   nativeBuildInputs = [ util-linux flex bison ];
19   configureFlags = [ "--enable-curses-graphics"
20                      "--disable-tty-graphics"
21                      "--with-owner=no"
22                      "--with-group=no"
23                      "--with-gamesdir=/tmp/unnethack"
24                    ];
26   makeFlags = [ "GAMEPERM=744" ];
27   patches = [
28     # fix regression with bison, merged in master
29     (fetchpatch {
30       name = "fix-bison.patch";
31       url = "https://github.com/UnNetHack/UnNetHack/commit/04f0a3a850a94eb8837ddcef31303968240d1c31.patch";
32       sha256 = "1zblbwqqz9nx16k6n31wi2hdvz775lvzmkjblmrx18nbm4ylj0n9";
33     })
34   ];
36   # Fails the build occasionally due to missing buid depends:
37   #   ./../sys/unix/unixmain.c:9:10: fatal error: date.h: No such file or directory
38   # TODO: remove once upstream issue is fixed:
39   #   https://github.com/UnNetHack/UnNetHack/issues/56
40   enableParallelBuilding = false;
42   postInstall = ''
43     cp -r /tmp/unnethack $out/share/unnethack/profile
44     mv $out/bin/unnethack $out/bin/.wrapped_unnethack
45     cat <<EOF >$out/bin/unnethack
46       #! ${stdenv.shell} -e
47       if [ ! -d ~/.unnethack ]; then
48         mkdir -p ~/.unnethack
49         cp -r $out/share/unnethack/profile/* ~/.unnethack
50         chmod -R +w ~/.unnethack
51       fi
53       ln -s ~/.unnethack /tmp/unnethack
55       cleanup() {
56         rm -rf /tmp/unnethack
57       }
58       trap cleanup EXIT
60       $out/bin/.wrapped_unnethack
61     EOF
62     chmod +x $out/bin/unnethack
63   '';
65   meta = with lib; {
66     description = "Fork of NetHack";
67     homepage = "https://unnethack.wordpress.com/";
68     license = "nethack";
69     platforms = platforms.all;
70     maintainers = with maintainers; [ abbradar ];
71   };