1{
2 lib,
3 stdenv,
4 fetchurl,
5 fetchPypi,
6 buildPythonPackage,
7 typing-extensions,
8 darwin,
9}:
10let
11 version = "16.0.19";
12 format = "setuptools";
13
14 devkit = {
15 aarch64-darwin = fetchurl {
16 url = "https://github.com/frida/frida/releases/download/${version}/frida-core-devkit-${version}-macos-arm64.tar.xz";
17 hash = "sha256-5VAZnpHQ5wjl7IM96GhIKOfFYHFDKKOoSjN1STna2UA=";
18 };
19
20 x86_64-linux = fetchurl {
21 url = "https://github.com/frida/frida/releases/download/${version}/frida-core-devkit-${version}-linux-x86_64.tar.xz";
22 hash = "sha256-yNXNqv8eCbpdQKFShpAh6rUCEuItrOSNNLOjESimPdk=";
23 };
24 }.${stdenv.hostPlatform.system}
25 or (throw "Unsupported system: ${stdenv.hostPlatform.system}");
26
27in
28buildPythonPackage rec {
29 pname = "frida-python";
30 inherit version;
31
32 src = fetchPypi {
33 pname = "frida";
34 inherit version;
35 hash = "sha256-rikIjjn9wA8VL/St/2JJTcueimn+q/URbt9lw/+nalY=";
36 };
37
38 postPatch = ''
39 mkdir assets
40 pushd assets
41 tar xvf ${devkit}
42 export FRIDA_CORE_DEVKIT=$PWD
43 popd
44 '';
45
46 env.NIX_LDFLAGS = lib.optionalString stdenv.hostPlatform.isDarwin "-framework AppKit";
47
48 propagatedBuildInputs = [ typing-extensions ];
49
50 buildInputs = lib.optionals stdenv.isDarwin [
51 darwin.apple_sdk.frameworks.AppKit
52 ];
53
54 pythonImportsCheck = [ "frida" ];
55
56 passthru = {
57 inherit devkit;
58 };
59
60 meta = {
61 description = "Dynamic instrumentation toolkit for developers, reverse-engineers, and security researchers (Python bindings)";
62 homepage = "https://www.frida.re";
63 license = lib.licenses.wxWindows;
64 maintainers = with lib.maintainers; [ s1341 ];
65 platforms = [ "aarch64-darwin" "x86_64-linux" ];
66 };
67}