summaryrefslogtreecommitdiff
path: root/pkgs/development/python-modules/mitmproxy-linux/default.nix
blob: 342ef131b55bbc2623df2096e7dc9c8fa3233e33 (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
{
  lib,
  buildPythonPackage,
  bpf-linker,
  rustPlatform,
  mitmproxy-rs,
}:

buildPythonPackage {
  pname = "mitmproxy-linux";
  inherit (mitmproxy-rs) version src cargoDeps;
  pyproject = true;

  postPatch = ''
    substituteInPlace ../mitmproxy-rs-*-vendor/aya-build-*/src/lib.rs \
      --replace-fail '"+nightly",' "" \
      --replace-fail '"-Z",' "" \
      --replace-fail '"build-std=core",' ""

    substituteInPlace mitmproxy-linux-ebpf/.cargo/config.toml \
      --replace-fail 'build-std = ["core"]' ""

    cp ${./fix-mitmproxy-linux-redirector-path.diff} tmp.diff
    substituteInPlace tmp.diff \
      --replace-fail @mitmproxy-linux-redirector@ $out/bin/mitmproxy-linux-redirector
    patch -p1 < tmp.diff
  '';

  env = {
    RUSTFLAGS = "-C target-feature=";
    RUSTC_BOOTSTRAP = 1;
  };

  buildAndTestSubdir = "mitmproxy-linux";

  nativeBuildInputs = [
    bpf-linker
    rustPlatform.cargoSetupHook
    rustPlatform.maturinBuildHook
  ];

  # repo has no python tests
  doCheck = false;

  pythonImportsCheck = [ "mitmproxy_linux" ];

  meta = {
    inherit (mitmproxy-rs.meta) changelog license maintainers;
    description = "Linux Rust bits in mitmproxy";
    homepage = "https://github.com/mitmproxy/mitmproxy_rs/tree/main/mitmproxy-linux";
    platforms = lib.platforms.linux;
  };
}