about summary refs log tree commit diff
path: root/nixpkgs/pkgs/tools/networking/wrk2/default.nix
blob: 7908143bdab3fb9a84046cdd65225cc7ed7f8b68 (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
{ stdenv, fetchFromGitHub, luajit, openssl, zlib }:

stdenv.mkDerivation rec {
  pname = "wrk2";
  version = "4.0.0-${builtins.substring 0 7 src.rev}";

  src = fetchFromGitHub {
    owner  = "giltene";
    repo   = "wrk2";
    rev    = "e0109df5b9de09251adb5f5848f223fbee2aa9f5";
    sha256 = "1aqdwmgdd74wq73f1zp28yqj91gd6p6nf9nbdfibl7mlklbzvak8";
  };

  buildInputs = [ luajit openssl zlib ];

  patchPhase = ''
    rm -rf deps/luajit && mkdir deps/luajit

    substituteInPlace ./Makefile \
      --replace '-lluajit' '-lluajit-5.1' \
      --replace '_BSD_SOURCE' '_DEFAULT_SOURCE' \
      --replace 'cd $(LDIR) && ./luajit' '${luajit}/bin/luajit' \
      --replace 'config.h Makefile $(LDIR)/libluajit.a' 'config.h Makefile'

    substituteInPlace ./src/script.c \
      --replace 'struct luaL_reg ' 'struct luaL_Reg '
  '';

  dontConfigure = true;
  installPhase = ''
    mkdir -p $out/bin
    mv ./wrk $out/bin/wrk2
  '';

  meta = {
    description = "Constant throughput, correct latency recording variant of wrk";
    homepage    = https://github.com/giltene/wrk2;
    license     = stdenv.lib.licenses.bsd3;
    platforms   = stdenv.lib.platforms.linux;
    maintainers = with stdenv.lib.maintainers; [ thoughtpolice ];
  };
}