1 { fetchFromGitHub, fetchpatch, lib, stdenv, cmake, pkg-config, python3, alsa-lib
2 , libX11, libGLU, SDL2, lua5_3, zlib, freetype, wavpack, icoutils
8 stdenv.mkDerivation rec {
12 src = fetchFromGitHub {
16 sha256 = "1l19ksmimg6b8zzjy0skyhh7z11ql7n5gvilkv7ay5x2b9ndbqwz";
17 fetchSubmodules = true;
21 # Can't use fetchpatch or fetchpatch2 because of https://github.com/NixOS/nixpkgs/issues/32084
22 # Using fetchurl instead is also not a good idea, see https://github.com/NixOS/nixpkgs/issues/32084#issuecomment-727223713
23 ./rename-VERSION-to-VERSION.txt.patch
25 name = "CVE-2021-43518.patch";
26 url = "https://salsa.debian.org/games-team/teeworlds/-/raw/a6c4b23c1ce73466e6d89bccbede70e61e8c9cba/debian/patches/CVE-2021-43518.patch";
27 hash = "sha256-2MmsucaaYjqLgMww1492gNmHmvBJm/NED+VV5pZDnBY=";
32 # set compiled-in DATA_DIR so resources can be found
33 substituteInPlace src/engine/shared/storage.cpp \
34 --replace '#define DATA_DIR "data"' \
35 '#define DATA_DIR "${placeholder "out"}/share/teeworlds/data"'
37 # Quote nonsense is a workaround for https://github.com/NixOS/nix/issues/661
38 substituteInPlace 'other/bundle/client/Info.plist.in' \
39 --replace ${"'"}''${TARGET_CLIENT}' 'teeworlds' \
40 --replace ${"'"}''${PROJECT_VERSION}' '${version}'
42 # Make sure some bundled dependencies are actually unbundled.
43 # This will fail compilation if one of these dependencies could not
44 # be found, instead of falling back to the bundled version.
45 rm -rf 'src/engine/external/wavpack/'
46 rm -rf 'src/engine/external/zlib/'
47 # md5, pnglite and json-parser (https://github.com/udp/json-parser)
48 # don't seem to be packaged in Nixpkgs, so don't unbundle them.
54 ] ++ lib.optionals (buildClient && stdenv.hostPlatform.isLinux) [
61 ] ++ lib.optionals stdenv.hostPlatform.isDarwin [
63 ] ++ lib.optionals buildClient ([
66 ] ++ lib.optionals stdenv.hostPlatform.isLinux [
73 "-DCLIENT=${if buildClient then "ON" else "OFF"}"
76 postInstall = lib.optionalString buildClient (lib.optionalString stdenv.hostPlatform.isLinux ''
77 # Convert and install desktop icon
78 mkdir -p $out/share/pixmaps
79 icotool --extract --index 1 --output $out/share/pixmaps/teeworlds.png $src/other/icons/teeworlds.ico
82 install -D $src/other/teeworlds.desktop $out/share/applications/teeworlds.desktop
83 '' + lib.optionalString stdenv.hostPlatform.isDarwin ''
84 mkdir -p "$out/Applications/teeworlds.app/Contents/MacOS"
85 mkdir -p "$out/Applications/teeworlds.app/Contents/Resources"
87 cp '../other/icons/teeworlds.icns' "$out/Applications/teeworlds.app/Contents/Resources/"
88 cp '../other/bundle/client/Info.plist.in' "$out/Applications/teeworlds.app/Contents/Info.plist"
89 cp '../other/bundle/client/PkgInfo' "$out/Applications/teeworlds.app/Contents/"
90 ln -s "$out/bin/teeworlds" "$out/Applications/teeworlds.app/Contents/MacOS/"
91 ln -s "$out/share/teeworlds/data" "$out/Applications/teeworlds.app/Contents/Resources/data"
94 passthru.tests.teeworlds = nixosTests.teeworlds;
97 description = "Retro multiplayer shooter game";
98 mainProgram = "teeworlds_srv";
101 Teeworlds is a free online multiplayer game, available for all
102 major operating systems. Battle with up to 12 players in a
103 variety of game modes, including Team Deathmatch and Capture The
104 Flag. You can even design your own maps!
107 homepage = "https://teeworlds.com/";
108 license = with lib.licenses; [
109 # See https://github.com/teeworlds/teeworlds/blob/master/license.txt
110 lib.licenses.zlib # Main license
111 cc-by-sa-30 # All content under 'datasrc' except the fonts
112 ofl # datasrc/fonts/SourceHanSans.ttc
113 free # datasrc/fonts/DejaVuSans.ttf
114 bsd2 # src/engine/external/json-parser/
115 bsd3 # src/engine/external/wavpack
116 # zlib src/engine/external/md5/
117 # zlib src/engine/external/pnglite/
118 # zlib src/engine/external/zlib/
120 maintainers = with lib.maintainers; [ astsmtl Luflosi ];
121 platforms = lib.platforms.unix;