nixpkgs/pkgs/games/uhexen2/default.nix
Graham Christensen c2b898da76 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 16:01:23 -04:00

67 lines
2.1 KiB
Nix

{ lib, fetchgit, SDL, stdenv, libogg, libvorbis, libmad, xdelta }:
stdenv.mkDerivation rec {
pname = "uhexen2";
version = "1.5.9";
src = fetchgit {
url = "https://git.code.sf.net/p/uhexen2/uhexen2";
sha256 = "0crdihbnb92awkikn15mzdpkj1x9s34xixf1r7fxxf762m60niks";
rev = "4ef664bc41e3998b0d2a55ff1166dadf34c936be";
};
buildInputs = [ SDL libogg libvorbis libmad xdelta ];
preBuild = ''
makeFiles=(
"engine/hexen2 glh2"
"engine/hexen2 clean"
"engine/hexen2 h2"
"engine/hexen2/server"
"engine/hexenworld/client glhw"
"engine/hexenworld/client clean"
"engine/hexenworld/client hw"
"engine/hexenworld/server"
"h2patch"
)
'';
buildPhase = ''
runHook preBuild
for makefile in "''${makeFiles[@]}"; do
local flagsArray=(
-j$NIX_BUILD_CORES
SHELL=$SHELL
$makeFlags "''${makeFlagsArray[@]}"
$buildFlags "''${buildFlagsArray[@]}"
)
echoCmd 'build flags' ""''${flagsArray[@]}""
make -C $makefile ""''${flagsArray[@]}""
unset flagsArray
done
runHook postBuild
'';
installPhase = ''
runHook preInstall
install -Dm755 engine/hexen2/{glhexen2,hexen2,server/h2ded} -t $out/bin
install -Dm755 engine/hexenworld/{client/glhwcl,client/hwcl,server/hwsv} -t $out/bin
install -Dm755 h2patch/h2patch -t $out/bin
runHook postInstall
'';
meta = with lib; {
broken = stdenv.isDarwin;
description = "A cross-platform port of Hexen II game";
longDescription = ''
Hammer of Thyrion (uHexen2) is a cross-platform port of Raven Software's Hexen II source.
It is based on an older linux port, Anvil of Thyrion.
HoT includes countless bug fixes, improved music, sound and video modes, opengl improvements,
support for many operating systems and architectures, and documentation among many others.
'';
homepage = "http://uhexen2.sourceforge.net/";
license = licenses.gpl2Plus;
maintainers = with maintainers; [ xdhampus ];
platforms = platforms.all;
};
}