Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
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 # NOTE: Check these revision changes when updating the package.
34 # https://github.com/radareorg/radare2/blob/master/libr/arch/p/arm/v35/Makefile#L25-L26
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 (finalAttrs: {
49 pname = "radare2";
50 version = "5.9.8";
51
52 src = fetchFromGitHub {
53 owner = "radare";
54 repo = "radare2";
55 tag = finalAttrs.version;
56 hash = "sha256-XSnv0yWEPlXHUPjf1Qu50AN3Gvgr0o6Q4e0dOyRdO9A=";
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.hostPlatform.isDarwin ''
70 install_name_tool -add_rpath $out/lib $out/lib/libr_io.${finalAttrs.version}.dylib
71 '';
72
73 mesonFlags = [
74 "-Dr2_gittap=${finalAttrs.version}"
75 "-Duse_sys_capstone=true"
76 "-Duse_sys_lz4=true"
77 "-Duse_sys_magic=true"
78 "-Duse_sys_openssl=true"
79 "-Duse_sys_xxhash=true"
80 "-Duse_sys_zip=true"
81 "-Duse_sys_zlib=true"
82 ];
83
84 enableParallelBuilding = true;
85
86 depsBuildBuild = [ buildPackages.stdenv.cc ];
87
88 strictDeps = true;
89
90 nativeBuildInputs = [
91 pkg-config
92 meson
93 ninja
94 python3
95 ];
96
97 buildInputs = [
98 capstone
99 file
100 readline
101 libusb-compat-0_1
102 libewf
103 perl
104 zlib
105 openssl
106 libuv
107 lz4
108 ]
109 ++ lib.optionals useX11 [
110 gtkdialog
111 vte
112 gtk2
113 ]
114 ++ lib.optionals rubyBindings [ ruby ]
115 ++ lib.optionals luaBindings [ lua ];
116
117 propagatedBuildInputs = [
118 # radare2 exposes r_lib which depends on these libraries
119 file # for its list of magic numbers (`libmagic`)
120 libzip
121 xxHash
122 ];
123
124 meta = with lib; {
125 description = "UNIX-like reverse engineering framework and command-line toolset";
126 longDescription = ''
127 r2 is a complete rewrite of radare. It provides a set of libraries, tools
128 and plugins to ease reverse engineering tasks. Distributed mostly under
129 LGPLv3, each plugin can have different licenses.
130
131 The radare project started as a simple command-line hexadecimal editor
132 focused on forensics. Today, r2 is a featureful low-level command-line
133 tool with support for scripting with the embedded JavaScript interpreter
134 or via r2pipe.
135
136 r2 can edit files on local hard drives, view kernel memory, and debug
137 programs locally or via a remote gdb/windbg servers. r2's wide
138 architecture support allows you to analyze, emulate, debug, modify, and
139 disassemble any binary.
140 '';
141 homepage = "https://radare.org";
142 changelog = "https://github.com/radareorg/radare2/releases/tag/${finalAttrs.version}";
143 license = with licenses; [
144 gpl3Only
145 lgpl3Only
146 ];
147 maintainers = with maintainers; [
148 azahi
149 raskin
150 makefu
151 mic92
152 arkivm
153 ];
154 mainProgram = "radare2";
155 platforms = platforms.unix;
156 };
157})