1 { lib, stdenv, fetchurl, fetchzip, makeWrapper, runCommand, makeDesktopItem
2 , xonotic-data, copyDesktopItems
4 unzip, libjpeg, zlib, libvorbis, curl
6 libX11, libGLU, libGL, libXpm, libXext, libXxf86vm, alsa-lib
14 , withDedicated ? true
20 name = "${pname}-${version}";
22 if withSDL && withGLX then
28 else if withDedicated then
30 else "-what-even-am-i";
33 description = "A free fast-paced first-person shooter";
35 Xonotic is a free, fast-paced first-person shooter that works on
36 Windows, macOS and Linux. The project is geared towards providing
37 addictive arena shooter gameplay which is all spawned and driven
38 by the community itself. Xonotic is a direct successor of the
39 Nexuiz project with years of development between them, and it
40 aims to become the best possible open-source FPS of its kind.
42 homepage = "https://www.xonotic.org/";
43 license = lib.licenses.gpl2Plus;
44 maintainers = with lib.maintainers; [ astsmtl zalakain ];
45 platforms = lib.platforms.linux;
48 desktopItem = makeDesktopItem {
51 comment = meta.description;
52 desktopName = "Xonotic";
53 categories = [ "Game" "Shooter" ];
55 startupNotify = false;
58 xonotic-unwrapped = stdenv.mkDerivation rec {
59 pname = "xonotic${variant}-unwrapped";
63 url = "https://dl.xonotic.org/xonotic-${version}-source.zip";
64 sha256 = "sha256-oagbpVqxUb8JdY5/WWFLLlFQ6EIkdT53lQvNB6KC6l0=";
67 nativeBuildInputs = [ unzip ];
68 buildInputs = [ libjpeg zlib libvorbis curl gmp ]
69 ++ lib.optionals withGLX [ libX11.dev libGLU.dev libGL.dev libXpm.dev libXext.dev libXxf86vm.dev alsa-lib.dev ]
70 ++ lib.optionals withSDL [ SDL2.dev ];
72 sourceRoot = "Xonotic/source/darkplaces";
74 # "debug", "release", "profile"
77 dontStrip = target != "release";
81 ./configure $configureFlags
85 buildPhase = (lib.optionalString withDedicated ''
86 make -j $NIX_BUILD_CORES sv-${target}
87 '' + lib.optionalString withGLX ''
88 make -j $NIX_BUILD_CORES cl-${target}
89 '' + lib.optionalString withSDL ''
90 make -j $NIX_BUILD_CORES sdl-${target}
93 make -j $NIX_BUILD_CORES
97 enableParallelBuilding = true;
100 for size in 16x16 24x24 32x32 48x48 64x64 72x72 96x96 128x128 192x192 256x256 512x512 1024x1024 scalable; do
101 install -Dm644 ../../misc/logos/xonotic_icon.svg \
102 $out/share/icons/hicolor/$size/xonotic.svg
104 '' + lib.optionalString withDedicated ''
105 install -Dm755 darkplaces-dedicated "$out/bin/xonotic-dedicated"
106 '' + lib.optionalString withGLX ''
107 install -Dm755 darkplaces-glx "$out/bin/xonotic-glx"
108 '' + lib.optionalString withSDL ''
109 install -Dm755 darkplaces-sdl "$out/bin/xonotic-sdl"
116 # Xonotic needs to find libcurl.so at runtime for map downloads
118 postFixup = lib.optionalString withDedicated ''
119 patchelf --add-needed ${curl.out}/lib/libcurl.so $out/bin/xonotic-dedicated
120 '' + lib.optionalString withGLX ''
122 --add-needed ${curl.out}/lib/libcurl.so \
123 --add-needed ${libvorbis}/lib/libvorbisfile.so \
124 --add-needed ${libvorbis}/lib/libvorbis.so \
125 --add-needed ${libGL.out}/lib/libGL.so \
127 '' + lib.optionalString withSDL ''
129 --add-needed ${curl.out}/lib/libcurl.so \
130 --add-needed ${libvorbis}/lib/libvorbisfile.so \
131 --add-needed ${libvorbis}/lib/libvorbis.so \
137 xonotic-data = fetchzip {
138 name = "xonotic-data";
139 url = "https://dl.xonotic.org/xonotic-${version}.zip";
140 sha256 = "sha256-/malKGbDdUnqG+bJOJ2f3zHb7hAGiNZdprczr2Fgb5E=";
143 rm -rf $(ls | grep -v "^data$" | grep -v "^key_0.d0pk$")
145 meta.hydraPlatforms = [];
146 passthru.version = version;
149 xonotic = runCommand "xonotic${variant}-${version}" {
150 inherit xonotic-unwrapped;
151 nativeBuildInputs = [ makeWrapper copyDesktopItems ];
152 desktopItems = [ desktopItem ];
161 '' + lib.optionalString withDedicated ''
162 ln -s ${xonotic-unwrapped}/bin/xonotic-dedicated $out/bin/
163 '' + lib.optionalString withGLX ''
164 ln -s ${xonotic-unwrapped}/bin/xonotic-glx $out/bin/xonotic-glx
165 ln -s $out/bin/xonotic-glx $out/bin/xonotic
166 '' + lib.optionalString withSDL ''
167 ln -s ${xonotic-unwrapped}/bin/xonotic-sdl $out/bin/xonotic-sdl
168 ln -sf $out/bin/xonotic-sdl $out/bin/xonotic
169 '' + lib.optionalString (withSDL || withGLX) ''
171 ln -s ${xonotic-unwrapped}/share/icons $out/share/icons
174 for binary in $out/bin/xonotic-*; do
175 wrapProgram $binary --add-flags "-basedir ${xonotic-data}" --prefix LD_LIBRARY_PATH : "${xonotic-unwrapped}/lib"