2022-07-01 19:49:54 +02:00
|
|
|
{ lib, stdenv, fetchurl, fetchzip, makeWrapper, runCommand, makeDesktopItem
|
2020-11-27 13:45:59 +01:00
|
|
|
, xonotic-data, copyDesktopItems
|
2014-01-01 17:47:32 +01:00
|
|
|
, # required for both
|
2023-03-20 19:30:58 +01:00
|
|
|
unzip, libjpeg, zlib, libvorbis, curl, freetype, libpng, libtheora
|
2014-01-01 17:47:32 +01:00
|
|
|
, # glx
|
2021-06-10 04:57:09 +02:00
|
|
|
libX11, libGLU, libGL, libXpm, libXext, libXxf86vm, alsa-lib
|
2014-01-01 17:47:32 +01:00
|
|
|
, # sdl
|
2017-05-26 11:28:17 +02:00
|
|
|
SDL2
|
2021-08-30 17:13:00 +02:00
|
|
|
, # blind
|
|
|
|
gmp
|
2013-05-02 13:13:11 +02:00
|
|
|
|
2020-04-02 21:58:05 +02:00
|
|
|
, withSDL ? true
|
|
|
|
, withGLX ? false
|
|
|
|
, withDedicated ? true
|
|
|
|
}:
|
2013-05-02 13:13:11 +02:00
|
|
|
|
2020-04-02 21:58:05 +02:00
|
|
|
let
|
|
|
|
pname = "xonotic";
|
2023-06-20 22:08:59 +02:00
|
|
|
version = "0.8.6";
|
2020-04-02 21:58:05 +02:00
|
|
|
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 13:13:11 +02:00
|
|
|
|
2011-11-06 14:54:03 +01: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-07 00:05:18 +02:00
|
|
|
Windows, macOS and Linux. The project is geared towards providing
|
2011-11-06 14:54:03 +01: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 21:58:05 +02:00
|
|
|
homepage = "https://www.xonotic.org/";
|
2021-01-15 05:31:39 +01:00
|
|
|
license = lib.licenses.gpl2Plus;
|
2022-06-23 00:51:46 +02:00
|
|
|
maintainers = with lib.maintainers; [ astsmtl zalakain ];
|
2021-01-15 05:31:39 +01:00
|
|
|
platforms = lib.platforms.linux;
|
2011-11-06 14:54:03 +01:00
|
|
|
};
|
2020-04-02 21:58:05 +02:00
|
|
|
|
|
|
|
desktopItem = makeDesktopItem {
|
|
|
|
name = "xonotic";
|
2020-12-19 21:11:21 +01:00
|
|
|
exec = "xonotic";
|
2020-04-02 21:58:05 +02:00
|
|
|
comment = meta.description;
|
|
|
|
desktopName = "Xonotic";
|
2022-02-22 15:56:15 +01:00
|
|
|
categories = [ "Game" "Shooter" ];
|
2020-04-02 21:58:05 +02:00
|
|
|
icon = "xonotic";
|
2022-02-22 15:56:15 +01:00
|
|
|
startupNotify = false;
|
2020-04-02 21:58:05 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
xonotic-unwrapped = stdenv.mkDerivation rec {
|
|
|
|
pname = "xonotic${variant}-unwrapped";
|
|
|
|
inherit version;
|
|
|
|
|
|
|
|
src = fetchurl {
|
2021-06-30 23:15:54 +02:00
|
|
|
url = "https://dl.xonotic.org/xonotic-${version}-source.zip";
|
2023-06-20 22:08:59 +02:00
|
|
|
hash = "sha256-i5KseBz/SuicEhoj6s197AWiqr7azMI6GdGglYtAEqg=";
|
2020-04-02 21:58:05 +02:00
|
|
|
};
|
|
|
|
|
2021-02-20 22:01:53 +01:00
|
|
|
nativeBuildInputs = [ unzip ];
|
2021-08-30 17:13:00 +02:00
|
|
|
buildInputs = [ libjpeg zlib libvorbis curl gmp ]
|
2022-10-06 18:38:53 +02:00
|
|
|
++ lib.optionals withGLX [ libX11.dev libGLU.dev libGL.dev libXpm.dev libXext.dev libXxf86vm.dev alsa-lib.dev ]
|
|
|
|
++ lib.optionals withSDL [ SDL2.dev ];
|
2020-04-02 21:58:05 +02:00
|
|
|
|
|
|
|
sourceRoot = "Xonotic/source/darkplaces";
|
|
|
|
|
|
|
|
# "debug", "release", "profile"
|
|
|
|
target = "release";
|
|
|
|
|
|
|
|
dontStrip = target != "release";
|
|
|
|
|
2021-08-30 17:13:00 +02:00
|
|
|
postConfigure = ''
|
|
|
|
pushd ../d0_blind_id
|
|
|
|
./configure $configureFlags
|
|
|
|
popd
|
|
|
|
'';
|
|
|
|
|
|
|
|
buildPhase = (lib.optionalString withDedicated ''
|
treewide: drop -l$NIX_BUILD_CORES
Passing `-l$NIX_BUILD_CORES` improperly limits the overall system load.
For a build machine which is configured to run `$B` builds where each
build gets `total cores / B` cores (`$C`), passing `-l $C` to make will
improperly limit the load to `$C` instead of `$B * $C`.
This effect becomes quite pronounced on machines with 80 cores, with
40 simultaneous builds and a cores limit of 2. On a machine with this
configuration, Nix will run 40 builds and make will limit the overall
system load to approximately 2. A build machine with this many cores
can happily run with a load approaching 80.
A non-solution is to oversubscribe the machine, by picking a larger
`$C`. However, there is no way to divide the number of cores in a way
which fairly subdivides the available cores when `$B` is greater than
1.
There has been exploration of passing a jobserver in to the sandbox,
or sharing a jobserver between all the builds. This is one option, but
relatively complicated and only supports make. Lots of other software
uses its own implementation of `-j` and doesn't support either `-l` or
the Make jobserver.
For the case of an interactive user machine, the user should limit
overall system load using `$B`, `$C`, and optionally systemd's
cpu/network/io limiting features.
Making this change should significantly improve the utilization of our
build farm, and improve the throughput of Hydra.
2022-09-22 17:17:14 +02:00
|
|
|
make -j $NIX_BUILD_CORES sv-${target}
|
2020-04-02 21:58:05 +02:00
|
|
|
'' + lib.optionalString withGLX ''
|
treewide: drop -l$NIX_BUILD_CORES
Passing `-l$NIX_BUILD_CORES` improperly limits the overall system load.
For a build machine which is configured to run `$B` builds where each
build gets `total cores / B` cores (`$C`), passing `-l $C` to make will
improperly limit the load to `$C` instead of `$B * $C`.
This effect becomes quite pronounced on machines with 80 cores, with
40 simultaneous builds and a cores limit of 2. On a machine with this
configuration, Nix will run 40 builds and make will limit the overall
system load to approximately 2. A build machine with this many cores
can happily run with a load approaching 80.
A non-solution is to oversubscribe the machine, by picking a larger
`$C`. However, there is no way to divide the number of cores in a way
which fairly subdivides the available cores when `$B` is greater than
1.
There has been exploration of passing a jobserver in to the sandbox,
or sharing a jobserver between all the builds. This is one option, but
relatively complicated and only supports make. Lots of other software
uses its own implementation of `-j` and doesn't support either `-l` or
the Make jobserver.
For the case of an interactive user machine, the user should limit
overall system load using `$B`, `$C`, and optionally systemd's
cpu/network/io limiting features.
Making this change should significantly improve the utilization of our
build farm, and improve the throughput of Hydra.
2022-09-22 17:17:14 +02:00
|
|
|
make -j $NIX_BUILD_CORES cl-${target}
|
2020-04-02 21:58:05 +02:00
|
|
|
'' + lib.optionalString withSDL ''
|
treewide: drop -l$NIX_BUILD_CORES
Passing `-l$NIX_BUILD_CORES` improperly limits the overall system load.
For a build machine which is configured to run `$B` builds where each
build gets `total cores / B` cores (`$C`), passing `-l $C` to make will
improperly limit the load to `$C` instead of `$B * $C`.
This effect becomes quite pronounced on machines with 80 cores, with
40 simultaneous builds and a cores limit of 2. On a machine with this
configuration, Nix will run 40 builds and make will limit the overall
system load to approximately 2. A build machine with this many cores
can happily run with a load approaching 80.
A non-solution is to oversubscribe the machine, by picking a larger
`$C`. However, there is no way to divide the number of cores in a way
which fairly subdivides the available cores when `$B` is greater than
1.
There has been exploration of passing a jobserver in to the sandbox,
or sharing a jobserver between all the builds. This is one option, but
relatively complicated and only supports make. Lots of other software
uses its own implementation of `-j` and doesn't support either `-l` or
the Make jobserver.
For the case of an interactive user machine, the user should limit
overall system load using `$B`, `$C`, and optionally systemd's
cpu/network/io limiting features.
Making this change should significantly improve the utilization of our
build farm, and improve the throughput of Hydra.
2022-09-22 17:17:14 +02:00
|
|
|
make -j $NIX_BUILD_CORES sdl-${target}
|
2021-08-30 17:13:00 +02:00
|
|
|
'') + ''
|
|
|
|
pushd ../d0_blind_id
|
treewide: drop -l$NIX_BUILD_CORES
Passing `-l$NIX_BUILD_CORES` improperly limits the overall system load.
For a build machine which is configured to run `$B` builds where each
build gets `total cores / B` cores (`$C`), passing `-l $C` to make will
improperly limit the load to `$C` instead of `$B * $C`.
This effect becomes quite pronounced on machines with 80 cores, with
40 simultaneous builds and a cores limit of 2. On a machine with this
configuration, Nix will run 40 builds and make will limit the overall
system load to approximately 2. A build machine with this many cores
can happily run with a load approaching 80.
A non-solution is to oversubscribe the machine, by picking a larger
`$C`. However, there is no way to divide the number of cores in a way
which fairly subdivides the available cores when `$B` is greater than
1.
There has been exploration of passing a jobserver in to the sandbox,
or sharing a jobserver between all the builds. This is one option, but
relatively complicated and only supports make. Lots of other software
uses its own implementation of `-j` and doesn't support either `-l` or
the Make jobserver.
For the case of an interactive user machine, the user should limit
overall system load using `$B`, `$C`, and optionally systemd's
cpu/network/io limiting features.
Making this change should significantly improve the utilization of our
build farm, and improve the throughput of Hydra.
2022-09-22 17:17:14 +02:00
|
|
|
make -j $NIX_BUILD_CORES
|
2021-08-30 17:13:00 +02:00
|
|
|
popd
|
2020-04-02 21:58:05 +02:00
|
|
|
'';
|
|
|
|
|
|
|
|
enableParallelBuilding = true;
|
|
|
|
|
2021-08-30 17:13:00 +02:00
|
|
|
installPhase = (''
|
2023-07-07 10:15:45 +02:00
|
|
|
install -Dm644 ../../misc/logos/xonotic_icon.svg \
|
|
|
|
$out/share/icons/hicolor/scalable/apps/xonotic.svg
|
|
|
|
pushd ../../misc/logos/icons_png
|
|
|
|
for img in *.png; do
|
|
|
|
size=''${img#xonotic_}
|
|
|
|
size=''${size%.png}
|
|
|
|
dimensions="''${size}x''${size}"
|
|
|
|
install -Dm644 $img \
|
|
|
|
$out/share/icons/hicolor/$dimensions/apps/xonotic.png
|
2020-04-03 09:22:38 +02:00
|
|
|
done
|
2023-07-07 10:15:45 +02:00
|
|
|
popd
|
2020-04-02 21:58:05 +02: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 17:13:00 +02:00
|
|
|
'') + ''
|
|
|
|
pushd ../d0_blind_id
|
|
|
|
make install
|
|
|
|
popd
|
2020-04-02 21:58:05 +02: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 \
|
2023-03-20 19:30:58 +01:00
|
|
|
--add-needed ${libvorbis}/lib/libvorbisenc.so \
|
2020-04-02 21:58:05 +02:00
|
|
|
--add-needed ${libvorbis}/lib/libvorbis.so \
|
|
|
|
--add-needed ${libGL.out}/lib/libGL.so \
|
2023-03-20 19:30:58 +01:00
|
|
|
--add-needed ${freetype}/lib/libfreetype.so \
|
|
|
|
--add-needed ${libpng}/lib/libpng.so \
|
|
|
|
--add-needed ${libtheora}/lib/libtheora.so \
|
2020-04-02 21:58:05 +02:00
|
|
|
$out/bin/xonotic-glx
|
|
|
|
'' + lib.optionalString withSDL ''
|
|
|
|
patchelf \
|
|
|
|
--add-needed ${curl.out}/lib/libcurl.so \
|
|
|
|
--add-needed ${libvorbis}/lib/libvorbisfile.so \
|
2023-03-20 19:30:58 +01:00
|
|
|
--add-needed ${libvorbis}/lib/libvorbisenc.so \
|
2020-04-02 21:58:05 +02:00
|
|
|
--add-needed ${libvorbis}/lib/libvorbis.so \
|
2023-03-20 19:30:58 +01:00
|
|
|
--add-needed ${freetype}/lib/libfreetype.so \
|
|
|
|
--add-needed ${libpng}/lib/libpng.so \
|
|
|
|
--add-needed ${libtheora}/lib/libtheora.so \
|
2020-04-02 21:58:05 +02:00
|
|
|
$out/bin/xonotic-sdl
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
in rec {
|
|
|
|
xonotic-data = fetchzip {
|
2021-06-22 23:44:58 +02:00
|
|
|
name = "xonotic-data";
|
2021-06-30 23:15:54 +02:00
|
|
|
url = "https://dl.xonotic.org/xonotic-${version}.zip";
|
2023-06-20 22:08:59 +02:00
|
|
|
hash = "sha256-Lhjpyk7idmfQAVn4YUb7diGyyKZQBfwNXxk2zMOqiZQ=";
|
2022-05-17 21:10:33 +02:00
|
|
|
postFetch = ''
|
2020-04-02 21:58:05 +02:00
|
|
|
cd $out
|
2021-08-30 17:13:00 +02:00
|
|
|
rm -rf $(ls | grep -v "^data$" | grep -v "^key_0.d0pk$")
|
2020-04-02 21:58:05 +02:00
|
|
|
'';
|
|
|
|
meta.hydraPlatforms = [];
|
|
|
|
passthru.version = version;
|
|
|
|
};
|
|
|
|
|
2021-08-15 17:12:23 +02:00
|
|
|
xonotic = runCommand "xonotic${variant}-${version}" {
|
2020-04-02 21:58:05 +02:00
|
|
|
inherit xonotic-unwrapped;
|
2020-11-27 13:45:59 +01:00
|
|
|
nativeBuildInputs = [ makeWrapper copyDesktopItems ];
|
|
|
|
desktopItems = [ desktopItem ];
|
2020-04-02 21:58:05 +02: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 09:22:38 +02:00
|
|
|
ln -s ${xonotic-unwrapped}/share/icons $out/share/icons
|
2020-11-27 13:45:59 +01:00
|
|
|
copyDesktopItems
|
2020-04-02 21:58:05 +02:00
|
|
|
'' + ''
|
|
|
|
for binary in $out/bin/xonotic-*; do
|
2021-08-30 17:13:00 +02:00
|
|
|
wrapProgram $binary --add-flags "-basedir ${xonotic-data}" --prefix LD_LIBRARY_PATH : "${xonotic-unwrapped}/lib"
|
2020-04-02 21:58:05 +02:00
|
|
|
done
|
|
|
|
'');
|
2011-11-06 14:54:03 +01:00
|
|
|
}
|