summary refs log tree commit diff
path: root/pkgs/games/zandronum/default.nix
blob: fa4c17649ac2ee659977072f98e13ffcd35e96da (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
{ stdenv, lib, fetchhg, cmake, pkgconfig, makeWrapper
, SDL, mesa, bzip2, zlib, fmod, libjpeg, fluidsynth, openssl, sqlite-amalgamation
, serverOnly ? false
}:

let suffix = lib.optionalString serverOnly "-server";

# FIXME: drop binary package when upstream fixes their protocol versioning
in stdenv.mkDerivation {
  name = "zandronum${suffix}-2.1.2";

  src = fetchhg {
    url = "https://bitbucket.org/Torr_Samaho/zandronum-stable";
    rev = "a3663b0061d5";
    sha256 = "0qwsnbwhcldwrirfk6hpiklmcj3a7dzh6pn36nizci6pcza07p56";
  };

  # I have no idea why would SDL and libjpeg be needed for the server part!
  # But they are.
  buildInputs = [ openssl bzip2 zlib SDL libjpeg ]
             ++ lib.optionals (!serverOnly) [ mesa fmod fluidsynth ];

  nativeBuildInputs = [ cmake pkgconfig makeWrapper ];

  preConfigure = ''
    ln -s ${sqlite-amalgamation}/* sqlite/
  '';

  cmakeFlags =
    lib.optional (!serverOnly) "-DFMOD_LIBRARY=${fmod}/lib/libfmodex.so"
    ++ lib.optional serverOnly "-DSERVERONLY=ON"
    ;

  enableParallelBuilding = true;

  hardening_format = false;

  installPhase = ''
    mkdir -p $out/bin
    mkdir -p $out/share/zandronum
    cp zandronum${suffix} \
       zandronum.pk3 \
       skulltag_actors.pk3 \
       ${lib.optionalString (!serverOnly) "liboutput_sdl.so"} \
       $out/share/zandronum

    # For some reason, while symlinks work for binary version, they don't for source one.
    makeWrapper $out/share/zandronum/zandronum${suffix} $out/bin/zandronum${suffix}
  '';

  postFixup = lib.optionalString (!serverOnly) ''
    patchelf --set-rpath $(patchelf --print-rpath $out/share/zandronum/zandronum):$out/share/zandronum \
      $out/share/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 ];
    platforms = platforms.linux;
    license = licenses.bsdOriginal;
  };
}