Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at devShellTools-shell 147 lines 4.6 kB view raw
1{ 2 fetchFromGitHub, 3 fetchpatch, 4 lib, 5 stdenv, 6 cmake, 7 pkg-config, 8 python3, 9 alsa-lib, 10 libX11, 11 libGLU, 12 SDL2, 13 lua5_3, 14 zlib, 15 freetype, 16 wavpack, 17 icoutils, 18 nixosTests, 19 buildClient ? true, 20}: 21 22stdenv.mkDerivation rec { 23 pname = "teeworlds"; 24 version = "0.7.5"; 25 26 src = fetchFromGitHub { 27 owner = "teeworlds"; 28 repo = "teeworlds"; 29 rev = version; 30 sha256 = "1l19ksmimg6b8zzjy0skyhh7z11ql7n5gvilkv7ay5x2b9ndbqwz"; 31 fetchSubmodules = true; 32 }; 33 34 patches = [ 35 # Can't use fetchpatch or fetchpatch2 because of https://github.com/NixOS/nixpkgs/issues/32084 36 # Using fetchurl instead is also not a good idea, see https://github.com/NixOS/nixpkgs/issues/32084#issuecomment-727223713 37 ./rename-VERSION-to-VERSION.txt.patch 38 (fetchpatch { 39 name = "CVE-2021-43518.patch"; 40 url = "https://salsa.debian.org/games-team/teeworlds/-/raw/a6c4b23c1ce73466e6d89bccbede70e61e8c9cba/debian/patches/CVE-2021-43518.patch"; 41 hash = "sha256-2MmsucaaYjqLgMww1492gNmHmvBJm/NED+VV5pZDnBY="; 42 }) 43 ]; 44 45 postPatch = '' 46 # set compiled-in DATA_DIR so resources can be found 47 substituteInPlace src/engine/shared/storage.cpp \ 48 --replace '#define DATA_DIR "data"' \ 49 '#define DATA_DIR "${placeholder "out"}/share/teeworlds/data"' 50 51 # Quote nonsense is a workaround for https://github.com/NixOS/nix/issues/661 52 substituteInPlace 'other/bundle/client/Info.plist.in' \ 53 --replace ${"'"}''${TARGET_CLIENT}' 'teeworlds' \ 54 --replace ${"'"}''${PROJECT_VERSION}' '${version}' 55 56 # Make sure some bundled dependencies are actually unbundled. 57 # This will fail compilation if one of these dependencies could not 58 # be found, instead of falling back to the bundled version. 59 rm -rf 'src/engine/external/wavpack/' 60 rm -rf 'src/engine/external/zlib/' 61 # md5, pnglite and json-parser (https://github.com/udp/json-parser) 62 # don't seem to be packaged in Nixpkgs, so don't unbundle them. 63 ''; 64 65 nativeBuildInputs = [ 66 cmake 67 pkg-config 68 ] 69 ++ lib.optionals (buildClient && stdenv.hostPlatform.isLinux) [ 70 icoutils 71 ]; 72 73 buildInputs = [ 74 python3 75 lua5_3 76 zlib 77 wavpack 78 ] 79 ++ lib.optionals buildClient ( 80 [ 81 SDL2 82 freetype 83 ] 84 ++ lib.optionals stdenv.hostPlatform.isLinux [ 85 libGLU 86 alsa-lib 87 libX11 88 ] 89 ); 90 91 cmakeFlags = [ 92 "-DCLIENT=${if buildClient then "ON" else "OFF"}" 93 ]; 94 95 postInstall = lib.optionalString buildClient ( 96 lib.optionalString stdenv.hostPlatform.isLinux '' 97 # Convert and install desktop icon 98 mkdir -p $out/share/pixmaps 99 icotool --extract --index 1 --output $out/share/pixmaps/teeworlds.png $src/other/icons/teeworlds.ico 100 101 # Install menu item 102 install -D $src/other/teeworlds.desktop $out/share/applications/teeworlds.desktop 103 '' 104 + lib.optionalString stdenv.hostPlatform.isDarwin '' 105 mkdir -p "$out/Applications/teeworlds.app/Contents/MacOS" 106 mkdir -p "$out/Applications/teeworlds.app/Contents/Resources" 107 108 cp '../other/icons/teeworlds.icns' "$out/Applications/teeworlds.app/Contents/Resources/" 109 cp '../other/bundle/client/Info.plist.in' "$out/Applications/teeworlds.app/Contents/Info.plist" 110 cp '../other/bundle/client/PkgInfo' "$out/Applications/teeworlds.app/Contents/" 111 ln -s "$out/bin/teeworlds" "$out/Applications/teeworlds.app/Contents/MacOS/" 112 ln -s "$out/share/teeworlds/data" "$out/Applications/teeworlds.app/Contents/Resources/data" 113 '' 114 ); 115 116 passthru.tests.teeworlds = nixosTests.teeworlds; 117 118 meta = { 119 description = "Retro multiplayer shooter game"; 120 mainProgram = "teeworlds_srv"; 121 122 longDescription = '' 123 Teeworlds is a free online multiplayer game, available for all 124 major operating systems. Battle with up to 12 players in a 125 variety of game modes, including Team Deathmatch and Capture The 126 Flag. You can even design your own maps! 127 ''; 128 129 homepage = "https://teeworlds.com/"; 130 license = with lib.licenses; [ 131 # See https://github.com/teeworlds/teeworlds/blob/master/license.txt 132 lib.licenses.zlib # Main license 133 cc-by-sa-30 # All content under 'datasrc' except the fonts 134 ofl # datasrc/fonts/SourceHanSans.ttc 135 free # datasrc/fonts/DejaVuSans.ttf 136 bsd2 # src/engine/external/json-parser/ 137 bsd3 # src/engine/external/wavpack 138 # zlib src/engine/external/md5/ 139 # zlib src/engine/external/pnglite/ 140 # zlib src/engine/external/zlib/ 141 ]; 142 maintainers = with lib.maintainers; [ 143 Luflosi 144 ]; 145 platforms = lib.platforms.unix; 146 }; 147}