1 { lib, stdenv, fetchurl, fetchzip, makeWrapper, runCommand, makeDesktopItem
2 , xonotic-data, copyDesktopItems
4 unzip, libjpeg, zlib, libvorbis, curl, freetype, libpng, libtheora
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 hash = "sha256-i5KseBz/SuicEhoj6s197AWiqr7azMI6GdGglYtAEqg=";
67 nativeBuildInputs = [ unzip ];
68 buildInputs = [ libjpeg zlib libvorbis curl gmp ]
69 ++ lib.optionals withGLX [ libX11 libGLU libGL libXpm libXext libXxf86vm alsa-lib ]
70 ++ lib.optionals withSDL [ SDL2 ];
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 install -Dm644 ../../misc/logos/xonotic_icon.svg \
101 $out/share/icons/hicolor/scalable/apps/xonotic.svg
102 pushd ../../misc/logos/icons_png
104 size=''${img#xonotic_}
106 dimensions="''${size}x''${size}"
107 install -Dm644 $img \
108 $out/share/icons/hicolor/$dimensions/apps/xonotic.png
111 '' + lib.optionalString withDedicated ''
112 install -Dm755 darkplaces-dedicated "$out/bin/xonotic-dedicated"
113 '' + lib.optionalString withGLX ''
114 install -Dm755 darkplaces-glx "$out/bin/xonotic-glx"
115 '' + lib.optionalString withSDL ''
116 install -Dm755 darkplaces-sdl "$out/bin/xonotic-sdl"
123 # Xonotic needs to find libcurl.so at runtime for map downloads
125 postFixup = lib.optionalString withDedicated ''
126 patchelf --add-needed ${curl.out}/lib/libcurl.so $out/bin/xonotic-dedicated
127 '' + lib.optionalString withGLX ''
129 --add-needed ${curl.out}/lib/libcurl.so \
130 --add-needed ${libvorbis}/lib/libvorbisfile.so \
131 --add-needed ${libvorbis}/lib/libvorbisenc.so \
132 --add-needed ${libvorbis}/lib/libvorbis.so \
133 --add-needed ${libGL.out}/lib/libGL.so \
134 --add-needed ${freetype}/lib/libfreetype.so \
135 --add-needed ${libpng}/lib/libpng.so \
136 --add-needed ${libtheora}/lib/libtheora.so \
138 '' + lib.optionalString withSDL ''
140 --add-needed ${curl.out}/lib/libcurl.so \
141 --add-needed ${libvorbis}/lib/libvorbisfile.so \
142 --add-needed ${libvorbis}/lib/libvorbisenc.so \
143 --add-needed ${libvorbis}/lib/libvorbis.so \
144 --add-needed ${freetype}/lib/libfreetype.so \
145 --add-needed ${libpng}/lib/libpng.so \
146 --add-needed ${libtheora}/lib/libtheora.so \
152 xonotic-data = fetchzip {
153 name = "xonotic-data";
154 url = "https://dl.xonotic.org/xonotic-${version}.zip";
155 hash = "sha256-Lhjpyk7idmfQAVn4YUb7diGyyKZQBfwNXxk2zMOqiZQ=";
158 rm -rf $(ls | grep -v "^data$" | grep -v "^key_0.d0pk$")
160 meta.hydraPlatforms = [];
161 inherit version pname;
164 xonotic = runCommand "xonotic${variant}-${version}" {
165 inherit xonotic-unwrapped version;
166 pname = "${pname}${variant}";
167 nativeBuildInputs = [ makeWrapper copyDesktopItems ];
168 desktopItems = [ desktopItem ];
174 '' + lib.optionalString withDedicated ''
175 ln -s ${xonotic-unwrapped}/bin/xonotic-dedicated $out/bin/
176 '' + lib.optionalString withGLX ''
177 ln -s ${xonotic-unwrapped}/bin/xonotic-glx $out/bin/xonotic-glx
178 ln -s $out/bin/xonotic-glx $out/bin/xonotic
179 '' + lib.optionalString withSDL ''
180 ln -s ${xonotic-unwrapped}/bin/xonotic-sdl $out/bin/xonotic-sdl
181 ln -sf $out/bin/xonotic-sdl $out/bin/xonotic
182 '' + lib.optionalString (withSDL || withGLX) ''
184 ln -s ${xonotic-unwrapped}/share/icons $out/share/icons
187 for binary in $out/bin/xonotic-*; do
188 wrapProgram $binary --add-flags "-basedir ${xonotic-data}" --prefix LD_LIBRARY_PATH : "${xonotic-unwrapped}/lib"