Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ lib
2, stdenv
3, fetchFromGitHub
4, fetchpatch
5, buildPackages
6, pkg-config
7, meson
8, ninja
9, libusb-compat-0_1
10, readline
11, libewf
12, perl
13, zlib
14, openssl
15, libuv
16, file
17, libzip
18, xxHash
19, gtk2
20, vte
21, gtkdialog
22, python3
23, ruby
24, lua
25, lz4
26, capstone
27, useX11 ? false
28, rubyBindings ? false
29, luaBindings ? false
30}:
31
32let
33 # FIXME: Compare revision with
34 # https://github.com/radareorg/radare2/blob/master/libr/arch/p/arm/v35/Makefile#L26-L27
35 arm64 = fetchFromGitHub {
36 owner = "radareorg";
37 repo = "vector35-arch-arm64";
38 rev = "55d73c6bbb94448a5c615933179e73ac618cf876";
39 hash = "sha256-pZxxp5xDg8mgkGEx7LaBSoKxNPyggFYA4um9YaO20LU=";
40 };
41 armv7 = fetchFromGitHub {
42 owner = "radareorg";
43 repo = "vector35-arch-armv7";
44 rev = "f270a6cc99644cb8e76055b6fa632b25abd26024";
45 hash = "sha256-YhfgJ7M8ys53jh1clOzj0I2yfJshXQm5zP0L9kMYsmk=";
46 };
47in
48stdenv.mkDerivation rec {
49 pname = "radare2";
50 version = "5.8.6";
51
52 src = fetchFromGitHub {
53 owner = "radare";
54 repo = "radare2";
55 rev = "refs/tags/${version}";
56 hash = "sha256-mKcwsxvWkeRNytGs+37jX9misxnQQgvKPY7LGNtRvZA=";
57 };
58
59 preBuild = ''
60 pushd ../libr/arch/p/arm/v35
61 cp -r ${arm64} arch-arm64
62 chmod -R +w arch-arm64
63
64 cp -r ${armv7} arch-armv7
65 chmod -R +w arch-armv7
66 popd
67 '';
68
69 postFixup = lib.optionalString stdenv.isDarwin ''
70 install_name_tool -add_rpath $out/lib $out/lib/libr_io.${version}.dylib
71 '';
72
73 mesonFlags = [
74 "-Duse_sys_capstone=true"
75 "-Duse_sys_magic=true"
76 "-Duse_sys_zip=true"
77 "-Duse_sys_xxhash=true"
78 "-Duse_sys_lz4=true"
79 "-Dr2_gittap=${version}"
80 ];
81
82 enableParallelBuilding = true;
83 depsBuildBuild = [ buildPackages.stdenv.cc ];
84
85 strictDeps = true;
86
87 nativeBuildInputs = [ pkg-config meson ninja python3 ];
88 buildInputs = [
89 capstone
90 file
91 readline
92 libusb-compat-0_1
93 libewf
94 perl
95 zlib
96 openssl
97 libuv
98 lz4
99 ] ++ lib.optionals useX11 [ gtkdialog vte gtk2 ]
100 ++ lib.optionals rubyBindings [ ruby ]
101 ++ lib.optionals luaBindings [ lua ];
102
103 propagatedBuildInputs = [
104 # radare2 exposes r_lib which depends on these libraries
105 file # for its list of magic numbers (`libmagic`)
106 libzip
107 xxHash
108 ];
109
110 meta = with lib; {
111 description = "UNIX-like reverse engineering framework and command-line tools";
112 homepage = "https://radare.org";
113 changelog = "https://github.com/radareorg/radare2/releases/tag/${version}";
114 license = licenses.gpl2Plus;
115 maintainers = with maintainers; [ azahi raskin makefu mic92 arkivm ];
116 platforms = platforms.unix;
117 };
118}