2022-04-24 16:40:56 +01:00
|
|
|
{ lib, stdenv, fetchurl, fetchpatch, fetchzip, makeWrapper, runCommand, makeDesktopItem
|
2020-11-27 12:45:59 +00:00
|
|
|
, xonotic-data, copyDesktopItems
|
2014-01-01 16:47:32 +00:00
|
|
|
, # required for both
|
2018-07-21 01:44:44 +01:00
|
|
|
unzip, libjpeg, zlib, libvorbis, curl
|
2014-01-01 16:47:32 +00:00
|
|
|
, # glx
|
2021-06-10 03:57:09 +01:00
|
|
|
libX11, libGLU, libGL, libXpm, libXext, libXxf86vm, alsa-lib
|
2014-01-01 16:47:32 +00:00
|
|
|
, # sdl
|
2017-05-26 10:28:17 +01:00
|
|
|
SDL2
|
2021-08-30 16:13:00 +01:00
|
|
|
, # blind
|
|
|
|
gmp
|
2013-05-02 12:13:11 +01:00
|
|
|
|
2020-04-02 20:58:05 +01:00
|
|
|
, withSDL ? true
|
|
|
|
, withGLX ? false
|
|
|
|
, withDedicated ? true
|
|
|
|
}:
|
2013-05-02 12:13:11 +01:00
|
|
|
|
2020-04-02 20:58:05 +01:00
|
|
|
let
|
|
|
|
pname = "xonotic";
|
|
|
|
version = "0.8.2";
|
|
|
|
name = "${pname}-${version}";
|
|
|
|
variant =
|
|
|
|
if withSDL && withGLX then
|
|
|
|
""
|
|
|
|
else if withSDL then
|
|
|
|
"-sdl"
|
|
|
|
else if withGLX then
|
|
|
|
"-glx"
|
|
|
|
else if withDedicated then
|
|
|
|
"-dedicated"
|
|
|
|
else "-what-even-am-i";
|
2013-05-02 12:13:11 +01:00
|
|
|
|
2011-11-06 13:54:03 +00:00
|
|
|
meta = {
|
|
|
|
description = "A free fast-paced first-person shooter";
|
|
|
|
longDescription = ''
|
|
|
|
Xonotic is a free, fast-paced first-person shooter that works on
|
2017-08-06 23:05:18 +01:00
|
|
|
Windows, macOS and Linux. The project is geared towards providing
|
2011-11-06 13:54:03 +00:00
|
|
|
addictive arena shooter gameplay which is all spawned and driven
|
|
|
|
by the community itself. Xonotic is a direct successor of the
|
|
|
|
Nexuiz project with years of development between them, and it
|
|
|
|
aims to become the best possible open-source FPS of its kind.
|
|
|
|
'';
|
2020-04-02 20:58:05 +01:00
|
|
|
homepage = "https://www.xonotic.org/";
|
2021-01-15 04:31:39 +00:00
|
|
|
license = lib.licenses.gpl2Plus;
|
|
|
|
maintainers = with lib.maintainers; [ astsmtl zalakain petabyteboy ];
|
|
|
|
platforms = lib.platforms.linux;
|
2011-11-06 13:54:03 +00:00
|
|
|
};
|
2020-04-02 20:58:05 +01:00
|
|
|
|
|
|
|
desktopItem = makeDesktopItem {
|
|
|
|
name = "xonotic";
|
2020-12-19 20:11:21 +00:00
|
|
|
exec = "xonotic";
|
2020-04-02 20:58:05 +01:00
|
|
|
comment = meta.description;
|
|
|
|
desktopName = "Xonotic";
|
2022-02-22 14:56:15 +00:00
|
|
|
categories = [ "Game" "Shooter" ];
|
2020-04-02 20:58:05 +01:00
|
|
|
icon = "xonotic";
|
2022-02-22 14:56:15 +00:00
|
|
|
startupNotify = false;
|
2020-04-02 20:58:05 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
xonotic-unwrapped = stdenv.mkDerivation rec {
|
|
|
|
pname = "xonotic${variant}-unwrapped";
|
|
|
|
inherit version;
|
|
|
|
|
|
|
|
src = fetchurl {
|
2021-06-30 22:15:54 +01:00
|
|
|
url = "https://dl.xonotic.org/xonotic-${version}-source.zip";
|
|
|
|
sha256 = "0axxw04fyz6jlfqd0kp7hdrqa0li31sx1pbipf2j5qp9wvqicsay";
|
2020-04-02 20:58:05 +01:00
|
|
|
};
|
|
|
|
|
2022-04-24 16:40:56 +01:00
|
|
|
patches = [
|
|
|
|
# Fix to make darkplaces compile under GCC 11
|
|
|
|
(fetchpatch {
|
|
|
|
name = "fix-darkplaces-gcc11";
|
|
|
|
url = "https://gitlab.com/xonotic/darkplaces/-/commit/5e9e998c1759bc0085c3273fc39f9ea6f72a7dc8.patch";
|
|
|
|
sha256 = "sha256-s0JettSg0AYr8V2mXKJ2QU125bBcX1BAu/yDciTWC5o=";
|
|
|
|
})
|
|
|
|
];
|
|
|
|
|
2021-02-20 21:01:53 +00:00
|
|
|
nativeBuildInputs = [ unzip ];
|
2021-08-30 16:13:00 +01:00
|
|
|
buildInputs = [ libjpeg zlib libvorbis curl gmp ]
|
2021-06-10 03:57:09 +01:00
|
|
|
++ lib.optional withGLX [ libX11.dev libGLU.dev libGL.dev libXpm.dev libXext.dev libXxf86vm.dev alsa-lib.dev ]
|
2020-04-02 20:58:05 +01:00
|
|
|
++ lib.optional withSDL [ SDL2.dev ];
|
|
|
|
|
|
|
|
sourceRoot = "Xonotic/source/darkplaces";
|
|
|
|
|
|
|
|
# "debug", "release", "profile"
|
|
|
|
target = "release";
|
|
|
|
|
|
|
|
dontStrip = target != "release";
|
|
|
|
|
2021-08-30 16:13:00 +01:00
|
|
|
postConfigure = ''
|
|
|
|
pushd ../d0_blind_id
|
|
|
|
./configure $configureFlags
|
|
|
|
popd
|
|
|
|
'';
|
|
|
|
|
|
|
|
buildPhase = (lib.optionalString withDedicated ''
|
2020-04-02 20:58:05 +01:00
|
|
|
make -j $NIX_BUILD_CORES -l $NIX_BUILD_CORES sv-${target}
|
|
|
|
'' + lib.optionalString withGLX ''
|
|
|
|
make -j $NIX_BUILD_CORES -l $NIX_BUILD_CORES cl-${target}
|
|
|
|
'' + lib.optionalString withSDL ''
|
|
|
|
make -j $NIX_BUILD_CORES -l $NIX_BUILD_CORES sdl-${target}
|
2021-08-30 16:13:00 +01:00
|
|
|
'') + ''
|
|
|
|
pushd ../d0_blind_id
|
|
|
|
make -j $NIX_BUILD_CORES -l $NIX_BUILD_CORES
|
|
|
|
popd
|
2020-04-02 20:58:05 +01:00
|
|
|
'';
|
|
|
|
|
|
|
|
enableParallelBuilding = true;
|
|
|
|
|
2021-08-30 16:13:00 +01:00
|
|
|
installPhase = (''
|
2020-04-03 08:22:38 +01:00
|
|
|
for size in 16x16 24x24 32x32 48x48 64x64 72x72 96x96 128x128 192x192 256x256 512x512 1024x1024 scalable; do
|
|
|
|
install -Dm644 ../../misc/logos/xonotic_icon.svg \
|
|
|
|
$out/share/icons/hicolor/$size/xonotic.svg
|
|
|
|
done
|
2020-04-02 20:58:05 +01:00
|
|
|
'' + lib.optionalString withDedicated ''
|
|
|
|
install -Dm755 darkplaces-dedicated "$out/bin/xonotic-dedicated"
|
|
|
|
'' + lib.optionalString withGLX ''
|
|
|
|
install -Dm755 darkplaces-glx "$out/bin/xonotic-glx"
|
|
|
|
'' + lib.optionalString withSDL ''
|
|
|
|
install -Dm755 darkplaces-sdl "$out/bin/xonotic-sdl"
|
2021-08-30 16:13:00 +01:00
|
|
|
'') + ''
|
|
|
|
pushd ../d0_blind_id
|
|
|
|
make install
|
|
|
|
popd
|
2020-04-02 20:58:05 +01:00
|
|
|
'';
|
|
|
|
|
|
|
|
# Xonotic needs to find libcurl.so at runtime for map downloads
|
|
|
|
dontPatchELF = true;
|
|
|
|
postFixup = lib.optionalString withDedicated ''
|
|
|
|
patchelf --add-needed ${curl.out}/lib/libcurl.so $out/bin/xonotic-dedicated
|
|
|
|
'' + lib.optionalString withGLX ''
|
|
|
|
patchelf \
|
|
|
|
--add-needed ${curl.out}/lib/libcurl.so \
|
|
|
|
--add-needed ${libvorbis}/lib/libvorbisfile.so \
|
|
|
|
--add-needed ${libvorbis}/lib/libvorbis.so \
|
|
|
|
--add-needed ${libGL.out}/lib/libGL.so \
|
|
|
|
$out/bin/xonotic-glx
|
|
|
|
'' + lib.optionalString withSDL ''
|
|
|
|
patchelf \
|
|
|
|
--add-needed ${curl.out}/lib/libcurl.so \
|
|
|
|
--add-needed ${libvorbis}/lib/libvorbisfile.so \
|
|
|
|
--add-needed ${libvorbis}/lib/libvorbis.so \
|
|
|
|
$out/bin/xonotic-sdl
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
in rec {
|
|
|
|
xonotic-data = fetchzip {
|
2021-06-22 22:44:58 +01:00
|
|
|
name = "xonotic-data";
|
2021-06-30 22:15:54 +01:00
|
|
|
url = "https://dl.xonotic.org/xonotic-${version}.zip";
|
2021-08-30 16:13:00 +01:00
|
|
|
sha256 = "15caj11v9hhr7w55w3rs1rspblzr9lg1crqivbn9pyyq0rif8cpl";
|
2020-04-02 20:58:05 +01:00
|
|
|
extraPostFetch = ''
|
|
|
|
cd $out
|
2021-08-30 16:13:00 +01:00
|
|
|
rm -rf $(ls | grep -v "^data$" | grep -v "^key_0.d0pk$")
|
2020-04-02 20:58:05 +01:00
|
|
|
'';
|
|
|
|
meta.hydraPlatforms = [];
|
|
|
|
passthru.version = version;
|
|
|
|
};
|
|
|
|
|
2021-08-15 16:12:23 +01:00
|
|
|
xonotic = runCommand "xonotic${variant}-${version}" {
|
2020-04-02 20:58:05 +01:00
|
|
|
inherit xonotic-unwrapped;
|
2020-11-27 12:45:59 +00:00
|
|
|
nativeBuildInputs = [ makeWrapper copyDesktopItems ];
|
|
|
|
desktopItems = [ desktopItem ];
|
2020-04-02 20:58:05 +01:00
|
|
|
passthru = {
|
|
|
|
inherit version;
|
|
|
|
meta = meta // {
|
|
|
|
hydraPlatforms = [];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
} (''
|
|
|
|
mkdir -p $out/bin
|
|
|
|
'' + lib.optionalString withDedicated ''
|
|
|
|
ln -s ${xonotic-unwrapped}/bin/xonotic-dedicated $out/bin/
|
|
|
|
'' + lib.optionalString withGLX ''
|
|
|
|
ln -s ${xonotic-unwrapped}/bin/xonotic-glx $out/bin/xonotic-glx
|
|
|
|
ln -s $out/bin/xonotic-glx $out/bin/xonotic
|
|
|
|
'' + lib.optionalString withSDL ''
|
|
|
|
ln -s ${xonotic-unwrapped}/bin/xonotic-sdl $out/bin/xonotic-sdl
|
|
|
|
ln -sf $out/bin/xonotic-sdl $out/bin/xonotic
|
|
|
|
'' + lib.optionalString (withSDL || withGLX) ''
|
|
|
|
mkdir -p $out/share
|
2020-04-03 08:22:38 +01:00
|
|
|
ln -s ${xonotic-unwrapped}/share/icons $out/share/icons
|
2020-11-27 12:45:59 +00:00
|
|
|
copyDesktopItems
|
2020-04-02 20:58:05 +01:00
|
|
|
'' + ''
|
|
|
|
for binary in $out/bin/xonotic-*; do
|
2021-08-30 16:13:00 +01:00
|
|
|
wrapProgram $binary --add-flags "-basedir ${xonotic-data}" --prefix LD_LIBRARY_PATH : "${xonotic-unwrapped}/lib"
|
2020-04-02 20:58:05 +01:00
|
|
|
done
|
|
|
|
'');
|
2011-11-06 13:54:03 +00:00
|
|
|
}
|