about summary refs log tree commit diff
path: root/nixpkgs/pkgs/games/openarena/default.nix
blob: 7ae0111cfe4b84b50c00f810c32fd48a02f584fe (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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
{ lib
, fetchzip
, fetchFromGitHub
, stdenv
, fetchpatch
, copyDesktopItems
, curl
, makeBinaryWrapper
, pkg-config
, which
, freetype
, libglvnd
, libjpeg
, libogg
, libvorbis
, libxmp
, openal
, SDL2
, speex
, makeDesktopItem
}:

let
  openarena-maps = fetchzip {
    name = "openarena-maps";
    url = "https://download.tuxfamily.org/openarena/rel/088/openarena-0.8.8.zip";
    hash = "sha256-Rup1n14k9sKcyVFYzFqPYV+BEBCnUNwpnFsnyGrhl20=";
  };
in
stdenv.mkDerivation (finalAttrs: {
  pname = "openarena";
  version = "unstable-2023-03-02";

  src = fetchFromGitHub {
    name = "openarena-source";
    owner = "OpenArena";
    repo = "engine";
    rev = "075cb860a4d2bc43e75e5f506eba7da877708aba";
    hash = "sha256-ofQKQyS3ti5TSN+zqwPFYuJiB9kvdER6zTWn8yrOpQU=";
  };

  patches = [
    # Fix Makefile `copyFiles` target
    # Related upstream issue: https://github.com/OpenArena/engine/issues/83
    (fetchpatch {
      url = "https://github.com/OpenArena/engine/commit/f2b424bd332e90a1e2592edd21c62bdb8cd05214.patch";
      hash = "sha256-legiXLtZAeG2t1esiBa37qkAgxPJVM7JLhjpxGUmWCo=";
    })
  ];

  nativeBuildInputs = [
    copyDesktopItems
    curl
    makeBinaryWrapper
    pkg-config
    which
  ];

  buildInputs = [
    freetype
    libglvnd
    libjpeg
    libogg
    libvorbis
    libxmp
    openal
    SDL2
    speex
  ];

  enableParallelBuilding = true;

  preConfigure = ''
    cp ${./Makefile.local} ./Makefile.local
  '';

  installTargets = [ "copyfiles" ];
  installFlags = [ "COPYDIR=$(out)/share/openarena" ];

  preInstall = ''
    mkdir -p $out/share/openarena
  '';

  postInstall = ''
    install -Dm644 misc/quake3.svg $out/share/icons/hicolor/scalable/apps/openarena.svg

    makeWrapper $out/share/openarena/openarena.* $out/bin/openarena
    makeWrapper $out/share/openarena/oa_ded.* $out/bin/oa_ded

    ln -s ${openarena-maps}/baseoa $out/share/openarena/baseoa
    ln -s ${openarena-maps}/missionpack $out/share/openarena/missionpack
  '';

  desktopItems = [
    (makeDesktopItem {
      name = "OpenArena";
      exec = "openarena";
      icon = "openarena";
      comment = "A fast-paced 3D first-person shooter, similar to id Software Inc.'s Quake III Arena";
      desktopName = "OpenArena";
      categories = [ "Game" "ActionGame" ];
    })
  ];

  meta = {
    description = "A fast-paced 3D first-person shooter, similar to id Software Inc.'s Quake III Arena";
    homepage = "http://openarena.ws/";
    license = lib.licenses.gpl2Plus;
    mainProgram = "openarena";
    maintainers = with lib.maintainers; [ drupol wyvie ];
    platforms = lib.platforms.linux;
  };
})