1 { lib, stdenv, SDL, SDL2, fetchurl, gzip, libvorbis, libmad, flac, libopus, opusfile, libogg, libxmp
2 , Cocoa, CoreAudio, CoreFoundation, IOKit, OpenGL
3 , copyDesktopItems, makeDesktopItem, pkg-config
4 , useSDL2 ? stdenv.isDarwin # TODO: CoreAudio fails to initialize with SDL 1.x for some reason.
7 stdenv.mkDerivation rec {
12 url = "mirror://sourceforge/quakespasm/quakespasm-${version}.tar.gz";
13 sha256 = "sha256-pjXqOyL5ILu0Tx5sfehYXbVsL11Abt9cgZJ4xkkBrnA=";
16 sourceRoot = "${pname}-${version}/Quake";
18 patches = lib.optionals stdenv.isDarwin [
19 # Makes Darwin Makefile use system libraries instead of ones from app bundle
20 ./quakespasm-darwin-makefile-improvements.patch
29 gzip libvorbis libmad flac libopus opusfile libogg libxmp
30 (if useSDL2 then SDL2 else SDL)
31 ] ++ lib.optionals stdenv.isDarwin [
32 Cocoa CoreAudio IOKit OpenGL
33 ] ++ lib.optionals (stdenv.isDarwin && useSDL2) [
39 # Makefile defaults, set here to enforce consistency on Darwin build
50 ] ++ lib.optionals useSDL2 [
51 "SDL_CONFIG=sdl2-config"
55 makefile = if (stdenv.isDarwin) then "Makefile.darwin" else "Makefile";
59 substituteInPlace Makefile --replace "/usr/local/games" "$out/bin"
60 substituteInPlace Makefile.darwin --replace "/usr/local/games" "$out/bin"
63 postInstall = lib.optionalString stdenv.isDarwin ''
64 # Let's build app bundle
65 mkdir -p $out/Applications/Quake.app/Contents/MacOS
66 mkdir -p $out/Applications/Quake.app/Contents/Resources
67 cp ../MacOSX/Info.plist $out/Applications/Quake.app/Contents/
68 cp ../MacOSX/QuakeSpasm.icns $out/Applications/Quake.app/Contents/Resources/
69 cp -r ../MacOSX/English.lproj $out/Applications/Quake.app/Contents/Resources/
70 ln -sf $out/bin/quake $out/Applications/Quake.app/Contents/MacOS/quake
72 substituteInPlace $out/Applications/Quake.app/Contents/Info.plist \
73 --replace '>''${EXECUTABLE_NAME}' '>quake'
74 substituteInPlace $out/Applications/Quake.app/Contents/Info.plist \
75 --replace '>''${PRODUCT_NAME}' '>QuakeSpasm'
78 enableParallelBuilding = true;
84 desktopName = "Quakespasm";
85 categories = [ "Game" ];
90 description = "An engine for iD software's Quake";
91 homepage = "http://quakespasm.sourceforge.net/";
93 QuakeSpasm is a modern, cross-platform Quake 1 engine based on FitzQuake.
94 It includes support for 64 bit CPUs and custom music playback, a new sound driver,
95 some graphical niceities, and numerous bug-fixes and other improvements.
96 Quakespasm utilizes either the SDL or SDL2 frameworks, so choose which one
97 works best for you. SDL is probably less buggy, but SDL2 has nicer features
98 and smoother mouse input - though no CD support.
101 platforms = platforms.unix;
102 maintainers = with maintainers; [ mikroskeem ];
103 mainProgram = "quake";