summary refs log tree commit diff
path: root/pkgs/games/spring/default.nix
blob: 8577db773e3f080f452b81edf875e0619bb10638 (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
{ lib
, stdenv
, asciidoc
, boost
, cmake
, curl
, docbook_xsl
, docbook_xsl_ns
, fetchurl
, freetype
, glew
, jdk
, libdevil
, libGL
, libGLU
, libunwind
, libvorbis
, makeWrapper
, minizip
, openal
, p7zip
, python3
, SDL2
, xorg
, xz
, zlib
, withAI ? true # support for AI Interfaces and Skirmish AIs
}:

stdenv.mkDerivation rec {
  pname = "spring";
  version = "106.0";

  src = fetchurl {
    url = "https://springrts.com/dl/buildbot/default/master/${version}/source/spring_${version}_src.tar.gz";
    sha256 = "sha256-mSA4ioIv68NMEB72lYnwDb1QOuWr1VHwu4+grAoHlV0=";
  };

  postPatch = ''
    patchShebangs .

    substituteInPlace ./rts/build/cmake/FindAsciiDoc.cmake \
      --replace "PATHS /usr /usr/share /usr/local /usr/local/share" "PATHS ${docbook_xsl}"\
      --replace "xsl/docbook/manpages" "share/xml/docbook-xsl/manpages"

    # The cmake included module correcly finds nix's glew, however
    # it has to be the bundled FindGLEW for headless or dedicated builds
    rm rts/build/cmake/FindGLEW.cmake
  '';

  cmakeFlags = [
    "-DCMAKE_BUILD_WITH_INSTALL_RPATH:BOOL=ON"
    "-DCMAKE_INSTALL_RPATH_USE_LINK_PATH:BOOL=ON"
    "-DPREFER_STATIC_LIBS:BOOL=OFF"
  ];

  nativeBuildInputs = [ cmake makeWrapper docbook_xsl docbook_xsl_ns asciidoc ];
  buildInputs = [
    boost
    curl
    freetype
    glew
    libdevil
    libGL
    libGLU
    libunwind
    libvorbis
    minizip
    openal
    p7zip
    SDL2
    xorg.libX11
    xorg.libXcursor
    xz
    zlib
  ]
  ++ lib.optionals withAI [ python3 jdk ];

  postInstall = ''
    wrapProgram "$out/bin/spring" \
      --prefix LD_LIBRARY_PATH : "${lib.makeLibraryPath [ stdenv.cc.cc ]}"
  '';

  meta = with lib; {
    homepage = "https://springrts.com/";
    description = "A powerful real-time strategy (RTS) game engine";
    license = licenses.gpl2Plus;
    maintainers = with maintainers; [ qknight domenkozar sorki ];
    platforms = [ "x86_64-linux" ];
  };
}