summary refs log tree commit diff
path: root/pkgs/games/openspades/default.nix
blob: 2203bb6337eb453998d6c86d8e6b28c3311cd4eb (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
{ stdenv, lib, fetchurl, cmake, curl, glew, makeWrapper, mesa, SDL2,
  SDL2_image, unzip, wget, zlib, withOpenal ? true, openal ? null }:

assert withOpenal -> openal != null;

stdenv.mkDerivation rec {
  name = "openspades-${version}";
  version = "0.0.12";

  src = fetchurl {
    url = "https://github.com/yvt/openspades/archive/v${version}.tar.gz";
    sha256 = "1aa848cck8qrp67ha9vrkzm3k24r2aiv1v4dxla6pi22rw98yxzm";
  };

  # https://github.com/yvt/openspades/issues/354
  postPatch = ''
    substituteInPlace Sources/Client/Client_Input.cpp --replace "isnan(" "std::isnan("
    substituteInPlace Sources/Client/Corpse.cpp --replace "isnan(" "std::isnan("
    substituteInPlace Sources/Draw/SWMapRenderer.cpp --replace "isnan(" "std::isnan(" --replace "isinf(" "std::isinf("
  '';

  nativeBuildInputs = 
    [ cmake curl glew makeWrapper mesa SDL2 SDL2_image unzip wget zlib ]
    ++ lib.optional withOpenal openal;

  cmakeFlags = [ "-DCMAKE_BUILD_TYPE=Release" "-DOPENSPADES_INSTALL_BINARY=bin" "-DOPENSPADES_RESOURCES=NO" ];

  enableParallelBuilding = true;

  devPack = fetchurl {
    url = "http://yvt.jp/files/programs/osppaks/DevPaks27.zip";
    sha256 = "05y7wldg70v5ys41fm0c8kipyspn524z4pglwr3p8h0gfz9n52v6";
  };

  preBuild = ''
    unzip -u -o $devPack -d Resources/DevPak
  '';

  NIX_CFLAGS_LINK = lib.optional withOpenal "-lopenal";

  meta = with stdenv.lib; {
    description = "A compatible client of Ace of Spades 0.75";
    homepage    = "https://github.com/yvt/openspades/";
    license     = licenses.gpl3;
    platforms   = platforms.linux;
  };
}