nixpkgs/pkgs/games/zandronum/default.nix
Cray Elliott 990ea8789d zandronum: 2.1.2 -> 3.0
remove sqlite-amalgamation and put it internal to the zandronum folder,
as it is only used by zandronum. Patches needed to avoid build impurities
and to get the correct protocol version to connect to public servers.

remove zandronum_bin as it is no longer needed
2017-09-15 11:26:11 -07:00

81 lines
2.8 KiB
Nix

{ stdenv, lib, fetchhg, cmake, pkgconfig, makeWrapper, callPackage
, soundfont-fluid, SDL, mesa, glew, bzip2, zlib, libjpeg, fluidsynth, openssl, gtk2, python3
, serverOnly ? false
}:
let
suffix = lib.optionalString serverOnly "-server";
fmod = callPackage ./fmod.nix { };
sqlite = callPackage ./sqlite.nix { };
# FIXME: drop binary package when upstream fixes their protocol versioning
in stdenv.mkDerivation {
name = "zandronum${suffix}-3.0";
src = fetchhg {
url = "https://bitbucket.org/Torr_Samaho/zandronum-stable";
rev = "dd3c3b57023f";
sha256 = "1f8pd8d2zjwdp6v9anp9yrkdbfhd2mp7svmnna0jiqgxjw6wkyls";
};
# zandronum tries to download sqlite now when running cmake, don't let it
# it also needs the current mercurial revision info embedded in gitinfo.h
# otherwise, the client will fail to connect to servers because the
# protocol version doesn't match.
patches = [ ./zan_configure_impurity.patch ./add_gitinfo.patch ./dont_update_gitinfo.patch ];
# I have no idea why would SDL and libjpeg be needed for the server part!
# But they are.
buildInputs = [ openssl bzip2 zlib SDL libjpeg sqlite ]
++ lib.optionals (!serverOnly) [ mesa glew fmod fluidsynth gtk2 ];
nativeBuildInputs = [ cmake pkgconfig makeWrapper python3 ];
preConfigure = ''
ln -s ${sqlite}/* sqlite/
sed -ie 's| restrict| _restrict|g' dumb/include/dumb.h \
dumb/src/it/*.c
'' + lib.optionalString serverOnly ''
sed -i \
-e "s@/usr/share/sounds/sf2/@${soundfont-fluid}/share/soundfonts/@g" \
-e "s@FluidR3_GM.sf2@FluidR3_GM2-2.sf2@g" \
src/sound/music_fluidsynth_mididevice.cpp
'';
cmakeFlags =
lib.optional (!serverOnly) "-DFMOD_LIBRARY=${fmod}/lib/libfmodex.so"
++ lib.optional serverOnly "-DSERVERONLY=ON"
;
enableParallelBuilding = true;
hardeningDisable = [ "format" ];
installPhase = ''
mkdir -p $out/bin
mkdir -p $out/lib/zandronum
cp zandronum${suffix} \
*.pk3 \
${lib.optionalString (!serverOnly) "liboutput_sdl.so"} \
$out/lib/zandronum
# For some reason, while symlinks work for binary version, they don't for source one.
makeWrapper $out/lib/zandronum/zandronum${suffix} $out/bin/zandronum${suffix} --prefix LD_LIBRARY_PATH : "$LD_LIBRARY_PATH:${fluidsynth}/lib"
'';
postFixup = lib.optionalString (!serverOnly) ''
patchelf --set-rpath $(patchelf --print-rpath $out/lib/zandronum/zandronum):$out/lib/zandronum \
$out/lib/zandronum/zandronum
'';
meta = with stdenv.lib; {
homepage = http://zandronum.com/;
description = "Multiplayer oriented port, based off Skulltag, for Doom and Doom II by id Software";
maintainers = with maintainers; [ lassulus ];
license = licenses.unfreeRedistributable;
platforms = platforms.linux;
};
}