1{
2 lib,
3 stdenv,
4 asciidoc,
5 boost,
6 cmake,
7 curl,
8 docbook_xsl,
9 docbook_xsl_ns,
10 fetchurl,
11 freetype,
12 glew,
13 jdk,
14 libdevil,
15 libGL,
16 libGLU,
17 libunwind,
18 libvorbis,
19 makeWrapper,
20 minizip,
21 openal,
22 p7zip,
23 python3,
24 SDL2,
25 xorg,
26 xz,
27 zlib,
28 withAI ? true, # support for AI Interfaces and Skirmish AIs
29}:
30
31stdenv.mkDerivation rec {
32 pname = "spring";
33 version = "106.0";
34
35 src = fetchurl {
36 url = "https://springrts.com/dl/buildbot/default/master/${version}/source/spring_${version}_src.tar.gz";
37 sha256 = "sha256-mSA4ioIv68NMEB72lYnwDb1QOuWr1VHwu4+grAoHlV0=";
38 };
39
40 postPatch = ''
41 patchShebangs .
42
43 substituteInPlace ./rts/build/cmake/FindAsciiDoc.cmake \
44 --replace "PATHS /usr /usr/share /usr/local /usr/local/share" "PATHS ${docbook_xsl}"\
45 --replace "xsl/docbook/manpages" "share/xml/docbook-xsl/manpages"
46
47 # The cmake included module correcly finds nix's glew, however
48 # it has to be the bundled FindGLEW for headless or dedicated builds
49 rm rts/build/cmake/FindGLEW.cmake
50 '';
51
52 cmakeFlags = [
53 "-DCMAKE_BUILD_WITH_INSTALL_RPATH:BOOL=ON"
54 "-DCMAKE_INSTALL_RPATH_USE_LINK_PATH:BOOL=ON"
55 "-DPREFER_STATIC_LIBS:BOOL=OFF"
56 ];
57
58 nativeBuildInputs = [
59 cmake
60 makeWrapper
61 docbook_xsl
62 docbook_xsl_ns
63 asciidoc
64 ];
65 buildInputs = [
66 boost
67 curl
68 freetype
69 glew
70 libdevil
71 libGL
72 libGLU
73 libunwind
74 libvorbis
75 minizip
76 openal
77 p7zip
78 SDL2
79 xorg.libX11
80 xorg.libXcursor
81 xz
82 zlib
83 ]
84 ++ lib.optionals withAI [
85 python3
86 jdk
87 ];
88
89 postInstall = ''
90 wrapProgram "$out/bin/spring" \
91 --prefix LD_LIBRARY_PATH : "${lib.makeLibraryPath [ stdenv.cc.cc ]}"
92 '';
93
94 meta = with lib; {
95 homepage = "https://springrts.com/";
96 description = "Powerful real-time strategy (RTS) game engine";
97 license = licenses.gpl2Plus;
98 maintainers = with maintainers; [
99 qknight
100 sorki
101 ];
102 platforms = [ "x86_64-linux" ];
103 broken = true;
104 };
105}