about summary refs log tree commit diff
path: root/pkgs/games/openarena/default.nix
blob: 1e396318bbbd0bfca335fab289b99a634de3679a (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
{ fetchurl, makeWrapper, patchelf, pkgs, stdenv, SDL, libogg, libvorbis }:

stdenv.mkDerivation rec {
  name = "openarena-${version}";
  version = "0.8.8";

  src = fetchurl {
    name = "openarena.zip";
    url = "http://openarena.ws/request.php?4";
    sha256 = "0jmc1cmdz1rcvqc9ilzib1kilpwap6v0d331l6q53wsibdzsz3ss";
  };

  buildInputs = [ pkgs.unzip patchelf makeWrapper];

  installPhase = let
    gameDir = "$out/openarena-$version";
    interpreter = "$(< \"$NIX_CC/nix-support/dynamic-linker\")";
    libPath = stdenv.lib.makeLibraryPath [ SDL libogg libvorbis ];
  in ''
    mkdir -pv $out/bin
    cd $out
    unzip $src

    ${if stdenv.system == "x86_64-linux" then ''
      patchelf --set-interpreter "${interpreter}" "${gameDir}/openarena.x86_64"
      makeWrapper "${gameDir}/openarena.x86_64" "$out/bin/openarena" \
        --prefix LD_LIBRARY_PATH : "${libPath}"
    '' else ''
      patchelf --set-interpreter "${interpreter}" "${gameDir}/openarena.i386"
      makeWrapper "${gameDir}/openarena.i386" "$out/bin/openarena" \
        --prefix LD_LIBRARY_PATH : "${libPath}"
    ''}
  '';

  meta = {
    description = "Crossplatform openarena client";
    homepage = http://openarena.ws/;
    maintainers = [ stdenv.lib.maintainers.wyvie ];
    platforms = stdenv.lib.platforms.linux;
    license = stdenv.lib.licenses.gpl2;
  };
}