nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at devShellTools-shell 133 lines 3.2 kB view raw
1{ 2 stdenv, 3 lib, 4 fetchFromGitHub, 5 buildEnv, 6 makeWrapper, 7 copyDesktopItems, 8 makeDesktopItem, 9 SDL2, 10 libGL, 11 curl, 12 openalSupport ? true, 13 openal, 14}: 15 16let 17 mkFlag = b: if b then "yes" else "no"; 18 19 games = import ./games.nix { inherit stdenv lib fetchFromGitHub; }; 20 21 wrapper = import ./wrapper.nix { 22 inherit 23 stdenv 24 lib 25 buildEnv 26 makeWrapper 27 yquake2 28 copyDesktopItems 29 makeDesktopItem 30 ; 31 }; 32 33 yquake2 = stdenv.mkDerivation rec { 34 pname = "yquake2"; 35 version = "8.51"; 36 37 src = fetchFromGitHub { 38 owner = "yquake2"; 39 repo = "yquake2"; 40 rev = "QUAKE2_${builtins.replaceStrings [ "." ] [ "_" ] version}"; 41 sha256 = "sha256-u8WXelbvfmbD+t6uTaE9z+kHBD3Re0P4SOUBL4MfAR4="; 42 }; 43 44 postPatch = '' 45 substituteInPlace src/client/curl/qcurl.c \ 46 --replace "\"libcurl.so.3\", \"libcurl.so.4\"" "\"${curl.out}/lib/libcurl.so\", \"libcurl.so.3\", \"libcurl.so.4\"" 47 '' 48 + lib.optionalString (openalSupport && !stdenv.hostPlatform.isDarwin) '' 49 substituteInPlace Makefile \ 50 --replace "\"libopenal.so.1\"" "\"${openal}/lib/libopenal.so.1\"" 51 ''; 52 53 buildInputs = [ 54 SDL2 55 libGL 56 curl 57 ] 58 ++ lib.optional openalSupport openal; 59 60 makeFlags = [ 61 "WITH_OPENAL=${mkFlag openalSupport}" 62 "WITH_SYSTEMWIDE=yes" 63 "WITH_SYSTEMDIR=$\{out}/share/games/quake2" 64 ]; 65 66 nativeBuildInputs = [ copyDesktopItems ]; 67 68 enableParallelBuilding = true; 69 70 installPhase = '' 71 runHook preInstall 72 # Yamagi Quake II expects all binaries (executables and libs) to be in the 73 # same directory. 74 mkdir -p $out/bin $out/lib/yquake2 $out/share/games/quake2/baseq2 75 cp -r release/* $out/lib/yquake2 76 ln -s $out/lib/yquake2/quake2 $out/bin/yquake2 77 ln -s $out/lib/yquake2/q2ded $out/bin/yq2ded 78 cp $src/stuff/yq2.cfg $out/share/games/quake2/baseq2 79 install -Dm644 stuff/icon/Quake2.png $out/share/pixmaps/yamagi-quake2.png; 80 runHook postInstall 81 ''; 82 83 desktopItems = [ 84 (makeDesktopItem { 85 name = "yquake2"; 86 exec = "yquake2"; 87 icon = "yamagi-quake2"; 88 desktopName = "yquake2"; 89 comment = "Yamagi Quake II client"; 90 categories = [ 91 "Game" 92 "Shooter" 93 ]; 94 }) 95 ]; 96 97 meta = with lib; { 98 description = "Yamagi Quake II client"; 99 homepage = "https://www.yamagi.org/quake2/"; 100 license = licenses.gpl2Plus; 101 platforms = platforms.unix; 102 maintainers = with maintainers; [ tadfisher ]; 103 }; 104 }; 105 106in 107{ 108 inherit yquake2; 109 110 yquake2-ctf = wrapper { 111 games = [ games.ctf ]; 112 name = "yquake2-ctf"; 113 inherit (games.ctf) description; 114 }; 115 116 yquake2-ground-zero = wrapper { 117 games = [ games.ground-zero ]; 118 name = "yquake2-ground-zero"; 119 inherit (games.ground-zero) description; 120 }; 121 122 yquake2-the-reckoning = wrapper { 123 games = [ games.the-reckoning ]; 124 name = "yquake2-the-reckoning"; 125 inherit (games.the-reckoning) description; 126 }; 127 128 yquake2-all-games = wrapper { 129 games = lib.attrValues games; 130 name = "yquake2-all-games"; 131 description = "Yamagi Quake II with all add-on games"; 132 }; 133}