summaryrefslogtreecommitdiffstats
path: root/packages/freeciv/default.nix
blob: a49069f1e073e4943026b066851c0be9d2b0e445 (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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
{
  lib,
  stdenv,
  fetchFromGitHub,
  autoreconfHook,
  lua5_3,
  pkg-config,
  python3,
  zlib,
  bzip2,
  curl,
  xz,
  gettext,
  libiconv,
  icu,
  SDL2,
  SDL2_mixer,
  SDL2_image,
  SDL2_ttf,
  SDL2_gfx,
  freetype,
  fluidsynth,
  sdl2Client ? false,
  gtkClient ? false,
  gtk3,
  wrapGAppsHook3,
  qtClient ? true,
  qt5,
  server ? true,
  readline,
  enableSqlite ? true,
  sqlite,
}:

stdenv.mkDerivation rec {
  pname = "freeciv";
  version = "3.1.5";

  src = fetchFromGitHub {
    owner = "freeciv";
    repo = "freeciv";
    rev = "R${lib.replaceStrings [ "." ] [ "_" ] version}";
    hash = "sha256-+kAV9Jz0aQpzeVUFp3so+rYbWOn52NuxRwE8kP5hzM8=";
  };

  postPatch = ''
    for f in {common,utility}/*.py; do
      substituteInPlace $f \
        --replace '/usr/bin/env python3' ${python3.interpreter}
    done
    for f in bootstrap/*.sh; do
      patchShebangs $f
    done
  '';

  nativeBuildInputs =
    [
      autoreconfHook
      pkg-config
    ]
    ++ lib.optionals qtClient [ qt5.wrapQtAppsHook ]
    ++ lib.optionals gtkClient [ wrapGAppsHook3 ];

  buildInputs =
    [
      lua5_3
      zlib
      bzip2
      curl
      xz
      gettext
      libiconv
      icu
      SDL2
      SDL2_mixer
      SDL2_image
      SDL2_ttf
      SDL2_gfx
      freetype
      fluidsynth
    ]
    ++ lib.optionals gtkClient [ gtk3 ]
    ++ lib.optionals qtClient [ qt5.qtbase ]
    ++ lib.optional server readline
    ++ lib.optional enableSqlite sqlite;

  dontWrapQtApps = true;
  dontWrapGApps = true;

  # configure is not smart enough to look for SDL2 headers under
  # .../SDL2, but thankfully $SDL2_PATH is almost exactly what we want
  preConfigure = ''
    export CPPFLAGS="$(echo $SDL2_PATH | sed 's#/nix/store/#-I/nix/store/#g')"
  '';
  configureFlags =
    [ "--enable-shared" ]
    ++ lib.optionals sdl2Client [
      "--enable-client=sdl2"
      "--enable-sdl-mixer=sdl2"
    ]
    ++ lib.optionals qtClient [
      "--enable-client=qt"
      "--enable-sdl-mixer=sdl2"
      "--with-qtver=qt5"
      "--with-qt5-includes=${qt5.qtbase.dev}/include"
    ]
    ++ lib.optionals gtkClient [ "--enable-client=gtk3.22" ]
    ++ lib.optional enableSqlite "--enable-fcdb=sqlite3"
    ++ lib.optional (!gtkClient) "--enable-fcmp=cli"
    ++ lib.optional (!server) "--disable-server";

  postFixup =
    lib.optionalString qtClient ''
      wrapQtApp $out/bin/freeciv-qt
    ''
    + lib.optionalString gtkClient ''
      wrapGApp $out/bin/freeciv-gtk3.22
    '';

  enableParallelBuilding = true;

  meta = {
    description = "Multiplayer (or single player), turn-based strategy game";
    longDescription = ''
      Freeciv is a Free and Open Source empire-building strategy game
      inspired by the history of human civilization. The game commences in
      prehistory and your mission is to lead your tribe from the stone age
      to the space age...
    '';
    homepage = "http://www.freeciv.org"; # http only
    license = lib.licenses.gpl2Plus;
    maintainers = with lib.maintainers; [ pierron ];
    platforms = lib.platforms.unix;
    hydraPlatforms = lib.platforms.linux; # sdl-config times out on darwin
    broken = qtClient && stdenv.hostPlatform.isDarwin; # Missing Qt5 development files
  };
}