nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5 cargo,
6 cmake,
7 ninja,
8 pkg-config,
9 rustPlatform,
10 rustc,
11 curl,
12 freetype,
13 libGLU,
14 libnotify,
15 libogg,
16 libX11,
17 opusfile,
18 pcre,
19 python3,
20 SDL2,
21 sqlite,
22 wavpack,
23 ffmpeg,
24 x264,
25 vulkan-headers,
26 vulkan-loader,
27 glslang,
28 spirv-tools,
29 gtest,
30 buildClient ? true,
31}:
32
33stdenv.mkDerivation rec {
34 pname = "ddnet";
35 version = "19.7";
36
37 src = fetchFromGitHub {
38 owner = "ddnet";
39 repo = "ddnet";
40 tag = version;
41 hash = "sha256-HjTkl4KOvQpAlLcUpfn5Ujr4IDfosUY2ueh0ZxE8KAs=";
42 };
43
44 cargoDeps = rustPlatform.fetchCargoVendor {
45 inherit pname version src;
46 hash = "sha256-VKGc4LQjt2FHbELLBKtV8rKpxjGBrzlA3m9BSdZ/6Z0=";
47 };
48
49 nativeBuildInputs = [
50 cmake
51 ninja
52 pkg-config
53 rustc
54 cargo
55 rustPlatform.cargoSetupHook
56 ];
57
58 nativeCheckInputs = [
59 gtest
60 ];
61
62 buildInputs = [
63 curl
64 libnotify
65 pcre
66 python3
67 sqlite
68 ]
69 ++ lib.optionals buildClient (
70 [
71 freetype
72 libGLU
73 libogg
74 opusfile
75 SDL2
76 wavpack
77 ffmpeg
78 x264
79 vulkan-loader
80 vulkan-headers
81 glslang
82 spirv-tools
83 ]
84 ++ lib.optionals stdenv.hostPlatform.isLinux [
85 libX11
86 ]
87 );
88
89 postPatch = ''
90 substituteInPlace src/engine/shared/storage.cpp \
91 --replace /usr/ $out/
92 '';
93
94 cmakeFlags = [
95 "-DAUTOUPDATE=OFF"
96 "-DCLIENT=${if buildClient then "ON" else "OFF"}"
97 ];
98
99 # Tests loop forever on Darwin for some reason
100 doCheck = !stdenv.hostPlatform.isDarwin;
101 checkTarget = "run_tests";
102
103 postInstall = lib.optionalString (!buildClient) ''
104 # DDNet's CMakeLists.txt automatically installs .desktop
105 # shortcuts and icons for the client, even if the client
106 # is not supposed to be built
107 rm -rf $out/share/applications
108 rm -rf $out/share/icons
109 rm -rf $out/share/metainfo
110 '';
111
112 preFixup = lib.optionalString (stdenv.hostPlatform.isDarwin && buildClient) ''
113 # Upstream links against <prefix>/lib while it installs this library in <prefix>/lib/ddnet
114 install_name_tool -change "$out/lib/libsteam_api.dylib" "$out/lib/ddnet/libsteam_api.dylib" "$out/bin/DDNet"
115 '';
116
117 meta = {
118 description = "Teeworlds modification with a unique cooperative gameplay";
119 longDescription = ''
120 DDraceNetwork (DDNet) is an actively maintained version of DDRace,
121 a Teeworlds modification with a unique cooperative gameplay.
122 Help each other play through custom maps with up to 64 players,
123 compete against the best in international tournaments,
124 design your own maps, or run your own server.
125 '';
126 homepage = "https://ddnet.org";
127 license = with lib.licenses; [
128 zlib
129 ofl
130 cc-by-sa-30
131 ];
132 maintainers = with lib.maintainers; [
133 ncfavier
134 Scrumplex
135 sirseruju
136 ];
137 mainProgram = "DDNet${lib.optionalString (!buildClient) "-Server"}";
138 };
139}