nixpkgs/pkgs/development/python-modules/r2pipe/default.nix
Profpatsch 4a7f99d55d treewide: with stdenv.lib; in meta -> with lib;
Part of: https://github.com/NixOS/nixpkgs/issues/108938

meta = with stdenv.lib;

is a widely used pattern. We want to slowly remove
the `stdenv.lib` indirection and encourage people
to use `lib` directly. Thus let’s start with the meta
field.

This used a rewriting script to mostly automatically
replace all occurances of this pattern, and add the
`lib` argument to the package header if it doesn’t
exist yet.

The script in its current form is available at
https://cs.tvl.fyi/depot@2f807d7f141068d2d60676a89213eaa5353ca6e0/-/blob/users/Profpatsch/nixpkgs-rewriter/default.nix
2021-01-11 10:38:22 +01:00

52 lines
1.4 KiB
Nix

{ stdenv
, lib
, python
, buildPythonPackage
, fetchPypi
, radare2
, coreutils
}:
buildPythonPackage rec {
pname = "r2pipe";
version = "1.5.3";
postPatch = let
r2lib = "${lib.getOutput "lib" radare2}/lib";
libr_core = "${r2lib}/libr_core${stdenv.hostPlatform.extensions.sharedLibrary}";
in
''
# Fix find_library, can be removed after
# https://github.com/NixOS/nixpkgs/issues/7307 is resolved.
substituteInPlace r2pipe/native.py --replace 'find_library("r_core")' "'${libr_core}'"
# Fix the default r2 executable
substituteInPlace r2pipe/open_sync.py --replace 'r2e = "radare2"' "r2e = '${radare2}/bin/radare2'"
substituteInPlace r2pipe/open_base.py --replace 'which("radare2")' "'${radare2}/bin/radare2'"
'';
src = fetchPypi {
inherit pname version;
sha256 = "8f3708195c8a6e91c5753940fd348cd821df1389d23b889b01b3e88acf407485";
};
# Tiny sanity check to make sure r2pipe finds radare2 (since r2pipe doesn't
# provide its own tests):
# Analyze ls with the fastest analysis and do nothing with the result.
postCheck = ''
${python.interpreter} <<EOF
import r2pipe
r2 = r2pipe.open('${coreutils}/bin/ls')
r2.cmd('a')
r2.quit()
EOF
'';
meta = with lib; {
description = "Interact with radare2";
homepage = "https://github.com/radare/radare2-r2pipe";
license = licenses.mit;
maintainers = with maintainers; [ timokau ];
};
}