summary refs log tree commit diff
path: root/pkgs/games/unnethack/default.nix
blob: ee3890aeea5b15468c6ec0189af6b612ebf09d2f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
{ stdenv, fetchgit, utillinux, ncurses, flex, bison }:

stdenv.mkDerivation rec {
  pname = "unnethack";
  version = "5.2.0";

  src = fetchgit {
    url = "https://github.com/UnNetHack/UnNetHack";
    rev = "refs/tags/${version}";
    sha256 = "088gd2c7v95f2pm9ky38i28sz73mnsksr2p2hhhflkchxncd21f1";
  };

  buildInputs = [ ncurses ];

  nativeBuildInputs = [ utillinux flex bison ];

  configureFlags = [ "--enable-curses-graphics"
                     "--disable-tty-graphics"
                     "--with-owner=no"
                     "--with-group=no"
                     "--with-gamesdir=/tmp/unnethack"
                   ];

  makeFlags = [ "GAMEPERM=744" ];

  enableParallelBuilding = true;

  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
  '';

  meta = with stdenv.lib; {
    description = "Fork of NetHack";
    homepage = https://unnethack.wordpress.com/;
    license = "nethack";
    platforms = platforms.all;
    maintainers = with maintainers; [ abbradar ];
  }; 
}