1{ lib
2, stdenv
3, fetchFromGitHub
4, gettext
5, installShellFiles
6, ncurses
7, ui ? "terminal"
8}:
9
10assert lib.elem ui [ "terminal" "curses" ];
11stdenv.mkDerivation (finalAttrs: {
12 pname = "2048-cli";
13 version = "unstable-2019-12-10";
14
15 src = fetchFromGitHub {
16 owner = "tiehuis";
17 repo = "2048-cli";
18 rev = "67439255df7d4f70209ca628d65128cd41d33e8d";
19 hash = "sha256-U7g2wCZgR7Lp/69ktQIZZ1cScll2baCequemTl3Mc3I=";
20 };
21
22 postPatch = ''
23 substituteInPlace Makefile \
24 --replace "-lcurses" "-lncurses"
25 '';
26
27 nativeBuildInputs = [
28 installShellFiles
29 ];
30
31 buildInputs = [
32 gettext
33 ]
34 ++ (lib.optional (ui == "curses") ncurses);
35
36 dontConfigure = true;
37
38 env.NIX_CFLAGS_COMPILE = "-I${lib.getDev gettext}/share/gettext/";
39
40 makeFlags = [
41 "CC=${stdenv.cc.targetPrefix}cc"
42 ui
43 ];
44
45 installPhase = ''
46 runHook preInstall
47
48 install -Dm755 -t $out/bin 2048
49 installManPage man/2048.6
50
51 runHook postInstall
52 '';
53
54 meta = {
55 homepage = "https://github.com/tiehuis/2048-cli";
56 description = "Game 2048 for your Linux terminal";
57 license = lib.licenses.mit;
58 maintainers = [ lib.maintainers.AndersonTorres ];
59 platforms = lib.platforms.unix;
60 mainProgram = "2048";
61 };
62})