aboutsummaryrefslogtreecommitdiff
path: root/srcds-pkgs/metamod-source.nix
blob: 2f9c92e741026c3390582d258e2be94cd9136b47 (plain)
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
{ lib, multiStdenv
, fetchFromGitHub, ed
, hl2sdk, ambuild, libfinite
}: let
  owner = "alliedmodders";
  buildno = "1155";
in multiStdenv.mkDerivation rec {
  pname = "metamod-source";
  version = "1.11_${buildno}";

  src = fetchFromGitHub rec {
    inherit owner;
    repo = pname;
    rev = "2009298c32735b6de1712ff88e2309c";
    fetchSubmodules = true;
    hash = "sha256-cPrllC3IljtV9SWn2NZbV8yHvehqLNGkZQ0RK07yCz4=";
  };

  nativeBuildInputs = [ ambuild ed ];

  hardeningDisable = [ "all" ];

  CXXFLAGS="-Wno-error=class-memaccess -Wno-error=format-truncation";
  
  postPatch = ''
    mkdir .git
    echo "ref: refs/heads/main" > .git/HEAD
    ed support/buildbot/generate_headers.py <<EOF
    /^def get_git_version/;/return/a
    def get_git_version():
      return '${buildno}', '${builtins.substring 0 7 src.rev}', '${src.rev}'
    .
    w
    EOF
    ed AMBuildScript <<EOF
    /tier1]/s|]|, '${libfinite}' ]|
    w
    EOF
  '';

  configurePhase = ''
    ln -s ${hl2sdk} ${hl2sdk.name}

    mkdir -p build
    pushd build
      python ../configure.py --sdks present
  '';

  buildPhase = ''
      ambuild
    popd
  '';

  installPhase = ''
    mkdir $out
    mv build/package $out/share
    cp -r $src $out/include
  '';

  meta = with lib; {
    description = "C++ plugin environment and detour library for the Source Engine";
    homepage = "https://github.com/${owner}/${pname}";
    platforms = platforms.unix;
    license = licenses.zlib;
  };
}