summary refs log tree commit diff
path: root/pkgs/games/quake3/wrapper/default.nix
blob: 3c777c5b27fbd0bca88982e663c3f9a4417d8fe5 (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
{ stdenv, buildEnv, lib, libGL, ioquake3, makeWrapper }:

{ paks, name ? (lib.head paks).name, description ? "" }:

let
  libPath = lib.makeLibraryPath [ libGL stdenv.cc.cc ];
  env = buildEnv {
    name = "quake3-env";
    paths = [ ioquake3 ] ++ paks;
  };

in stdenv.mkDerivation {
  name = "${name}-${ioquake3.name}";

  nativeBuildInputs = [ makeWrapper ];

  buildCommand = ''
    mkdir -p $out/bin

    # We add Mesa to the end of $LD_LIBRARY_PATH to provide fallback
    # software rendering. GCC is needed so that libgcc_s.so can be found
    # when Mesa is used.
    makeWrapper ${env}/bin/ioquake3.* $out/bin/quake3 \
      --suffix-each LD_LIBRARY_PATH ':' "${libPath}" \
      --add-flags "+set fs_basepath ${env} +set r_allowSoftwareGL 1"

    makeWrapper ${env}/bin/ioq3ded.* $out/bin/quake3-server \
      --add-flags "+set fs_basepath ${env}"
  '';

  meta = {
    inherit description;
  };
}