summary refs log tree commit diff
path: root/pkgs/games/2048-cli/default.nix
blob: 7ef923215d6d4f68843a5ac16693024648dc3c16 (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
59
60
61
{ lib
, stdenv
, fetchFromGitHub
, gettext
, installShellFiles
, ncurses
, ui ? "terminal"
}:

assert lib.elem ui [ "terminal" "curses" ];
stdenv.mkDerivation (finalAttrs: {
  pname = "2048-cli";
  version = "unstable-2019-12-10";

  src = fetchFromGitHub {
    owner = "tiehuis";
    repo = "2048-cli";
    rev = "67439255df7d4f70209ca628d65128cd41d33e8d";
    hash = "sha256-U7g2wCZgR7Lp/69ktQIZZ1cScll2baCequemTl3Mc3I=";
  };

  postPatch = ''
    substituteInPlace Makefile \
      --replace "-lcurses" "-lncurses"
  '';

  nativeBuildInputs = [
    installShellFiles
  ];

  buildInputs = [
    gettext
  ]
  ++ (lib.optional (ui == "curses") ncurses);

  dontConfigure = true;

  env.NIX_CFLAGS_COMPILE = "-I${lib.getDev gettext}/share/gettext/";

  makeFlags = [
    "CC=${stdenv.cc.targetPrefix}cc"
    ui
  ];

  installPhase = ''
    runHook preInstall

    install -Dm755 -t $out/bin 2048
    installManPage man/2048.6

    runHook postInstall
  '';

  meta = {
    homepage = "https://github.com/tiehuis/2048-cli";
    description = "The game 2048 for your Linux terminal";
    license = lib.licenses.mit;
    maintainers = [ lib.maintainers.AndersonTorres ];
    platforms = lib.platforms.unix;
  };
})