about summary refs log tree commit diff
path: root/pkgs/games/quake2/yquake2/default.nix
blob: c831163be9709a71e34cf3052912939a66d63c82 (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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
{ stdenv, lib, fetchFromGitHub, buildEnv, cmake, makeWrapper
, SDL2, libGL
, oggSupport ? true, libogg, libvorbis
, openalSupport ? true, openal
, zipSupport ? true, zlib
, Cocoa, OpenAL
}:

let
  mkFlag = b: if b then "ON" else "OFF";

  games = import ./games.nix { inherit stdenv lib fetchFromGitHub cmake; };

  wrapper = import ./wrapper.nix { inherit stdenv lib buildEnv makeWrapper yquake2; };

  yquake2 = stdenv.mkDerivation rec {
    pname = "yquake2";
    version = "7.30";

    src = fetchFromGitHub {
      owner = "yquake2";
      repo = "yquake2";
      rev = "QUAKE2_${builtins.replaceStrings ["."] ["_"] version}";
      sha256 = "0xfr620k1hns70dckv6k0kc72jbiwyghcys904jpriv5x94lnrlc";
    };

    enableParallelBuilding = true;

    nativeBuildInputs = [ cmake ];

    buildInputs = [ SDL2 libGL ]
      ++ lib.optionals stdenv.isDarwin [ Cocoa OpenAL ]
      ++ lib.optionals oggSupport [ libogg libvorbis ]
      ++ lib.optional openalSupport openal
      ++ lib.optional zipSupport zlib;

    cmakeFlags = [
      "-DCMAKE_BUILD_TYPE=Release"
      "-DOGG_SUPPORT=${mkFlag oggSupport}"
      "-DOPENAL_SUPPORT=${mkFlag openalSupport}"
      "-DZIP_SUPPORT=${mkFlag zipSupport}"
      "-DSYSTEMWIDE_SUPPORT=ON"
    ];

    preConfigure = ''
      # Since we can't expand $out in `cmakeFlags`
      cmakeFlags="$cmakeFlags -DSYSTEMDIR=$out/share/games/quake2"
    '';

    installPhase = ''
      # Yamagi Quake II expects all binaries (executables and libs) to be in the
      # same directory.
      mkdir -p $out/bin $out/lib/yquake2 $out/share/games/quake2
      cp -r release/* $out/lib/yquake2
      ln -s $out/lib/yquake2/quake2 $out/bin/yquake2
      ln -s $out/lib/yquake2/q2ded $out/bin/yq2ded
      cp $src/stuff/yq2.cfg $out/share/games/quake2
    '';

    meta = with stdenv.lib; {
      description = "Yamagi Quake II client";
      homepage = "https://www.yamagi.org/quake2/";
      license = licenses.gpl2;
      platforms = platforms.unix;
      maintainers = with maintainers; [ tadfisher ];
    };
  };

in {
  inherit yquake2;

  yquake2-ctf = wrapper {
    games = [ games.ctf ];
    name = "yquake2-ctf";
    inherit (games.ctf) description;
  };

  yquake2-ground-zero = wrapper {
    games = [ games.ground-zero ];
    name = "yquake2-ground-zero";
    inherit (games.ground-zero) description;
  };

  yquake2-the-reckoning = wrapper {
    games = [ games.the-reckoning ];
    name = "yquake2-the-reckoning";
    inherit (games.the-reckoning) description;
  };

  yquake2-all-games = wrapper {
    games = lib.attrValues games;
    name = "yquake2-all-games";
    description = "Yamagi Quake II with all add-on games";
  };
}