depot/third_party/nixpkgs/pkgs/development/tools/analysis/radare2/default.nix
Default email 92b3d6365d Project import generated by Copybara.
GitOrigin-RevId: 412b9917cea092f3d39f9cd5dead4effd5bc4053
2022-10-30 16:09:59 +01:00

119 lines
2.8 KiB
Nix

{ lib
, stdenv
, fetchFromGitHub
, buildPackages
, pkg-config
, libusb-compat-0_1
, readline
, libewf
, perl
, zlib
, openssl
, libuv
, file
, libzip
, xxHash
, gtk2
, vte
, gtkdialog
, python3
, ruby
, lua
, capstone
, useX11 ? false
, rubyBindings ? false
, pythonBindings ? false
, luaBindings ? false
}:
let
# FIXME: Compare revision with https://github.com/radareorg/radare2/blob/master/libr/asm/arch/arm/v35arm64/Makefile#L20
arm64 = fetchFromGitHub {
owner = "radareorg";
repo = "vector35-arch-arm64";
rev = "9ab2b0bedde459dc86e079718333de4a63bbbacb";
sha256 = "sha256-2KLtjgCqHzBBlo9ImZ8WJ1bsWy/kdJCjCFxlLE+HxoI=";
};
armv7 = fetchFromGitHub {
owner = "radareorg";
repo = "vector35-arch-armv7";
rev = "dde39f69ffea19fc37e681874b12cb4707bc4f30";
sha256 = "sha256-bnWQc0dScM9rhIdzf+iVXvMqYWq/bguEAUQPaZRgdlU=";
};
in
stdenv.mkDerivation rec {
pname = "radare2";
version = "5.7.2";
src = fetchFromGitHub {
owner = "radare";
repo = "radare2";
rev = version;
sha256 = "sha256-TZeW+9buJvCOudHsLTMITFpRUlmNpo71efc3xswJoPw=";
};
preBuild = ''
cp -r ${arm64} libr/asm/arch/arm/v35arm64/arch-arm64
chmod -R +w libr/asm/arch/arm/v35arm64/arch-arm64
cp -r ${armv7} libr/asm/arch/arm/v35arm64/arch-armv7
chmod -R +w libr/asm/arch/arm/v35arm64/arch-armv7
'';
postFixup = lib.optionalString stdenv.isDarwin ''
for file in $out/bin/rasm2 $out/bin/ragg2 $out/bin/rabin2 $out/lib/libr_asm.${version}.dylib $out/lib/libr_anal.${version}.dylib; do
install_name_tool -change libcapstone.4.dylib ${capstone}/lib/libcapstone.4.dylib $file
done
'';
WITHOUT_PULL = "1";
makeFlags = [
"GITTAP=${version}"
"RANLIB=${stdenv.cc.bintools.bintools}/bin/${stdenv.cc.bintools.targetPrefix}ranlib"
"CC=${stdenv.cc.targetPrefix}cc"
"HOST_CC=${stdenv.cc.targetPrefix}cc"
];
configureFlags = [
"--with-sysmagic"
"--with-syszip"
"--with-sysxxhash"
"--with-syscapstone"
"--with-openssl"
];
enableParallelBuilding = true;
depsBuildBuild = [ buildPackages.stdenv.cc ];
nativeBuildInputs = [ pkg-config ];
buildInputs = [
capstone
file
readline
libusb-compat-0_1
libewf
perl
zlib
openssl
libuv
] ++ lib.optionals useX11 [ gtkdialog vte gtk2 ]
++ lib.optionals rubyBindings [ ruby ]
++ lib.optionals pythonBindings [ python3 ]
++ lib.optionals luaBindings [ lua ];
propagatedBuildInputs = [
# radare2 exposes r_lib which depends on these libraries
file # for its list of magic numbers (`libmagic`)
libzip
xxHash
];
meta = with lib; {
description = "unix-like reverse engineering framework and commandline tools";
homepage = "https://radare.org/";
license = licenses.gpl2Plus;
maintainers = with maintainers; [ raskin makefu mic92 arkivm ];
platforms = platforms.unix;
};
}