1{ stdenv
2, lib
3, python
4, buildPythonPackage
5, fetchPypi
6, radare2
7, coreutils
8, pythonOlder
9}:
10
11buildPythonPackage rec {
12 pname = "r2pipe";
13 version = "1.8.0";
14 format = "setuptools";
15
16 disabled = pythonOlder "3.7";
17
18 postPatch = let
19 r2lib = "${lib.getOutput "lib" radare2}/lib";
20 libr_core = "${r2lib}/libr_core${stdenv.hostPlatform.extensions.sharedLibrary}";
21 in
22 ''
23 # Fix find_library, can be removed after
24 # https://github.com/NixOS/nixpkgs/issues/7307 is resolved.
25 substituteInPlace r2pipe/native.py --replace 'find_library("r_core")' "'${libr_core}'"
26
27 # Fix the default r2 executable
28 substituteInPlace r2pipe/open_sync.py --replace 'r2e = "radare2"' "r2e = '${radare2}/bin/radare2'"
29 substituteInPlace r2pipe/open_base.py --replace 'which("radare2")' "'${radare2}/bin/radare2'"
30 '';
31
32 src = fetchPypi {
33 inherit pname version;
34 hash = "sha256-T1w4QG0KBPBekETd+nMNbvPF2mgBZgQ/jhWcP9694mg=";
35 };
36
37 # Tiny sanity check to make sure r2pipe finds radare2 (since r2pipe doesn't
38 # provide its own tests):
39 # Analyze ls with the fastest analysis and do nothing with the result.
40 postCheck = ''
41 ${python.interpreter} <<EOF
42 import r2pipe
43 r2 = r2pipe.open('${coreutils}/bin/ls')
44 r2.cmd('a')
45 EOF
46 '';
47
48 meta = with lib; {
49 description = "Interact with radare2";
50 homepage = "https://github.com/radare/radare2-r2pipe";
51 license = licenses.mit;
52 maintainers = with maintainers; [ timokau ];
53 };
54}