Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at devShellTools-shell 132 lines 3.6 kB view raw
1{ 2 lib, 3 stdenv, 4 SDL, 5 SDL2, 6 fetchurl, 7 gzip, 8 libGL, 9 libGLU, 10 libvorbis, 11 libmad, 12 flac, 13 libopus, 14 opusfile, 15 libogg, 16 libxmp, 17 copyDesktopItems, 18 makeDesktopItem, 19 pkg-config, 20 useSDL2 ? stdenv.hostPlatform.isDarwin, # TODO: CoreAudio fails to initialize with SDL 1.x for some reason. 21}: 22 23stdenv.mkDerivation rec { 24 pname = "quakespasm"; 25 version = "0.96.3"; 26 27 src = fetchurl { 28 url = "mirror://sourceforge/quakespasm/quakespasm-${version}.tar.gz"; 29 sha256 = "sha256-tXjWzkpPf04mokRY8YxLzI04VK5iUuuZgu6B2V5QGA4="; 30 }; 31 32 sourceRoot = "${pname}-${version}/Quake"; 33 34 patches = lib.optionals stdenv.hostPlatform.isDarwin [ 35 # Makes Darwin Makefile use system libraries instead of ones from app bundle 36 ./quakespasm-darwin-makefile-improvements.patch 37 ]; 38 39 # Quakespasm tries to set a 10.6 deployment target, but that’s too low for SDL2. 40 postPatch = '' 41 sed -i Makefile.darwin -e '/-mmacosx-version-min/d' 42 ''; 43 44 nativeBuildInputs = [ 45 copyDesktopItems 46 pkg-config 47 ]; 48 49 buildInputs = [ 50 gzip 51 libGL 52 libGLU 53 libvorbis 54 libmad 55 flac 56 libopus 57 opusfile 58 libogg 59 libxmp 60 (if useSDL2 then SDL2 else SDL) 61 ]; 62 63 buildFlags = [ 64 "DO_USERDIRS=1" 65 # Makefile defaults, set here to enforce consistency on Darwin build 66 "USE_CODEC_WAVE=1" 67 "USE_CODEC_MP3=1" 68 "USE_CODEC_VORBIS=1" 69 "USE_CODEC_FLAC=1" 70 "USE_CODEC_OPUS=1" 71 "USE_CODEC_MIKMOD=0" 72 "USE_CODEC_UMX=0" 73 "USE_CODEC_XMP=1" 74 "MP3LIB=mad" 75 "VORBISLIB=vorbis" 76 ] 77 ++ lib.optionals useSDL2 [ 78 "SDL_CONFIG=sdl2-config" 79 "USE_SDL2=1" 80 ]; 81 82 makefile = if (stdenv.hostPlatform.isDarwin) then "Makefile.darwin" else "Makefile"; 83 84 preInstall = '' 85 mkdir -p "$out/bin" 86 substituteInPlace Makefile --replace "/usr/local/games" "$out/bin" 87 substituteInPlace Makefile.darwin --replace "/usr/local/games" "$out/bin" 88 ''; 89 90 postInstall = lib.optionalString stdenv.hostPlatform.isDarwin '' 91 # Let's build app bundle 92 mkdir -p $out/Applications/Quake.app/Contents/MacOS 93 mkdir -p $out/Applications/Quake.app/Contents/Resources 94 cp ../MacOSX/Info.plist $out/Applications/Quake.app/Contents/ 95 cp ../MacOSX/QuakeSpasm.icns $out/Applications/Quake.app/Contents/Resources/ 96 cp -r ../MacOSX/English.lproj $out/Applications/Quake.app/Contents/Resources/ 97 ln -sf $out/bin/quake $out/Applications/Quake.app/Contents/MacOS/quake 98 99 substituteInPlace $out/Applications/Quake.app/Contents/Info.plist \ 100 --replace '>''${EXECUTABLE_NAME}' '>quake' 101 substituteInPlace $out/Applications/Quake.app/Contents/Info.plist \ 102 --replace '>''${PRODUCT_NAME}' '>QuakeSpasm' 103 ''; 104 105 enableParallelBuilding = true; 106 107 desktopItems = [ 108 (makeDesktopItem { 109 name = "quakespasm"; 110 exec = "quake"; 111 desktopName = "Quakespasm"; 112 categories = [ "Game" ]; 113 }) 114 ]; 115 116 meta = with lib; { 117 description = "Engine for iD software's Quake"; 118 homepage = "https://quakespasm.sourceforge.net/"; 119 longDescription = '' 120 QuakeSpasm is a modern, cross-platform Quake 1 engine based on FitzQuake. 121 It includes support for 64 bit CPUs and custom music playback, a new sound driver, 122 some graphical niceities, and numerous bug-fixes and other improvements. 123 Quakespasm utilizes either the SDL or SDL2 frameworks, so choose which one 124 works best for you. SDL is probably less buggy, but SDL2 has nicer features 125 and smoother mouse input - though no CD support. 126 ''; 127 128 platforms = platforms.unix; 129 maintainers = with maintainers; [ mikroskeem ]; 130 mainProgram = "quake"; 131 }; 132}