aboutsummaryrefslogtreecommitdiff
path: root/srcds-pkgs/extensions/SM-Memory.nix
blob: 5d1761a132cb74904834f0c5fd6ef9265957239c (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
{ lib, multiStdenv, fetchFromGitHub
, metamod-source, sourcemod, ambuild
, ed
}:
multiStdenv.mkDerivation rec {
  pname = "SM-Memory";
  version = "1.5.1";

  src = fetchFromGitHub {
    owner = "Scags";
    repo = pname;
    rev = "V${version}";
    sha256 = "031nbx18hhqgnryzy00rv5bc8v1k7fbkb3677ndm7nkif13p12aa";
  };

  nativeBuildInputs = [ ambuild sourcemod ed ];

  patchPhase = ''
    pushd pawn/sourcemod/scripting
      substituteInPlace memtest_{func,vec}.sp --replace smmem_ smmem/
      ed memtest.sp <<EOF
    /#include/a
    #include <smmem/dynlib.inc>
    .
    w
    EOF
    popd
  '';

  configurePhase = ''
    cd build
    python ../configure.py \
      --sm-path ${sourcemod.src} \
      --mms-path ${metamod-source.src}
  '';

  buildPhase = ''
    ambuild
    pushd package/addons/sourcemod/scripting
      mkdir -p ../plugins/disabled
      for i in *.sp; do
        spcomp -i include $i -o ../plugins/disabled/''${i%.sp}.smx
      done
    popd
  '';

  installPhase = ''
    mkdir $out
    mv package $out/share
  '';
}