about summary refs log tree commit diff
path: root/pkgs/development/python-modules/frida-python/default.nix
blob: d73e5645e517704e525bd350019fcabee6de8b20 (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
{
  lib,
  stdenv,
  fetchurl,
  fetchPypi,
  buildPythonPackage,
  typing-extensions,
  darwin,
}:
let
  version = "16.0.19";
  format = "setuptools";

  devkit = {
    aarch64-darwin = fetchurl {
      url = "https://github.com/frida/frida/releases/download/${version}/frida-core-devkit-${version}-macos-arm64.tar.xz";
      hash = "sha256-5VAZnpHQ5wjl7IM96GhIKOfFYHFDKKOoSjN1STna2UA=";
    };

    x86_64-linux = fetchurl {
      url = "https://github.com/frida/frida/releases/download/${version}/frida-core-devkit-${version}-linux-x86_64.tar.xz";
      hash = "sha256-yNXNqv8eCbpdQKFShpAh6rUCEuItrOSNNLOjESimPdk=";
    };
  }.${stdenv.hostPlatform.system}
    or (throw "Unsupported system: ${stdenv.hostPlatform.system}");

in
buildPythonPackage rec {
  pname = "frida-python";
  inherit version;

  src = fetchPypi {
    pname = "frida";
    inherit version;
    hash = "sha256-rikIjjn9wA8VL/St/2JJTcueimn+q/URbt9lw/+nalY=";
  };

  postPatch = ''
    mkdir assets
    pushd assets
    tar xvf ${devkit}
    export FRIDA_CORE_DEVKIT=$PWD
    popd
  '';

  env.NIX_LDFLAGS = lib.optionalString stdenv.hostPlatform.isDarwin "-framework AppKit";

  propagatedBuildInputs = [ typing-extensions ];

  buildInputs = lib.optionals stdenv.isDarwin [
    darwin.apple_sdk.frameworks.AppKit
  ];

  pythonImportsCheck = [ "frida" ];

  passthru = {
    inherit devkit;
  };

  meta = {
    description = "Dynamic instrumentation toolkit for developers, reverse-engineers, and security researchers (Python bindings)";
    homepage = "https://www.frida.re";
    license = lib.licenses.wxWindows;
    maintainers = with lib.maintainers; [ s1341 ];
    platforms = [ "aarch64-darwin" "x86_64-linux" ];
  };
}