2021-03-30 10:10:56 +00:00
|
|
|
|
{ lib
|
2023-08-09 10:04:52 +00:00
|
|
|
|
, pkgs # for passthru.plugins
|
2021-03-30 10:10:56 +00:00
|
|
|
|
, stdenv
|
|
|
|
|
, fetchurl
|
|
|
|
|
, pkg-config
|
|
|
|
|
, libusb-compat-0_1
|
|
|
|
|
, readline
|
|
|
|
|
, libewf
|
|
|
|
|
, perl
|
|
|
|
|
, zlib
|
|
|
|
|
, openssl
|
|
|
|
|
, file
|
2023-08-05 14:11:24 +00:00
|
|
|
|
, libmspack
|
2021-03-30 10:10:56 +00:00
|
|
|
|
, libzip
|
|
|
|
|
, lz4
|
|
|
|
|
, xxHash
|
2023-08-05 14:11:24 +00:00
|
|
|
|
, xz
|
2021-03-30 10:10:56 +00:00
|
|
|
|
, meson
|
2022-10-25 16:31:45 +00:00
|
|
|
|
, python3
|
2021-03-30 10:10:56 +00:00
|
|
|
|
, cmake
|
|
|
|
|
, ninja
|
|
|
|
|
, capstone
|
|
|
|
|
, tree-sitter
|
|
|
|
|
}:
|
|
|
|
|
|
2023-08-09 10:04:52 +00:00
|
|
|
|
let rizin = stdenv.mkDerivation rec {
|
2021-03-30 10:10:56 +00:00
|
|
|
|
pname = "rizin";
|
2023-09-17 08:29:38 +00:00
|
|
|
|
version = "0.6.2";
|
2021-03-30 10:10:56 +00:00
|
|
|
|
|
|
|
|
|
src = fetchurl {
|
2021-04-11 10:25:18 +00:00
|
|
|
|
url = "https://github.com/rizinorg/rizin/releases/download/v${version}/rizin-src-v${version}.tar.xz";
|
2023-09-17 08:29:38 +00:00
|
|
|
|
hash = "sha256-4poAo+IgBL3RAUbShrHM4OBhltQarkcpqvydeDIf+Gs=";
|
2021-03-30 10:10:56 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
mesonFlags = [
|
2021-04-11 10:25:18 +00:00
|
|
|
|
"-Duse_sys_capstone=enabled"
|
|
|
|
|
"-Duse_sys_magic=enabled"
|
|
|
|
|
"-Duse_sys_libzip=enabled"
|
|
|
|
|
"-Duse_sys_zlib=enabled"
|
|
|
|
|
"-Duse_sys_lz4=enabled"
|
2023-08-05 14:11:24 +00:00
|
|
|
|
"-Duse_sys_lzma=enabled"
|
|
|
|
|
"-Duse_sys_xxhash=enabled"
|
2021-04-11 10:25:18 +00:00
|
|
|
|
"-Duse_sys_openssl=enabled"
|
2023-08-05 14:11:24 +00:00
|
|
|
|
"-Duse_sys_libmspack=enabled"
|
2021-04-11 10:25:18 +00:00
|
|
|
|
"-Duse_sys_tree_sitter=enabled"
|
2023-08-09 10:04:52 +00:00
|
|
|
|
# this is needed for wrapping (adding plugins) to work
|
|
|
|
|
"-Dportable=true"
|
2021-03-30 10:10:56 +00:00
|
|
|
|
];
|
|
|
|
|
|
2023-08-09 10:04:52 +00:00
|
|
|
|
# Normally, Rizin only looks for files in the install prefix. With
|
|
|
|
|
# portable=true, it instead looks for files in relation to the parent
|
|
|
|
|
# of the directory of the binary file specified in /proc/self/exe,
|
|
|
|
|
# caching it. This patch replaces the entire logic to only look at
|
|
|
|
|
# the env var NIX_RZ_PREFIX
|
|
|
|
|
patches = [ ./librz-wrapper-support.patch ];
|
|
|
|
|
|
2022-09-16 21:44:36 +00:00
|
|
|
|
nativeBuildInputs = [
|
|
|
|
|
pkg-config
|
|
|
|
|
meson
|
2022-10-25 16:31:45 +00:00
|
|
|
|
(python3.withPackages (pp: with pp; [
|
|
|
|
|
pyyaml
|
|
|
|
|
]))
|
2022-09-16 21:44:36 +00:00
|
|
|
|
ninja
|
|
|
|
|
cmake
|
|
|
|
|
];
|
2021-04-11 10:25:18 +00:00
|
|
|
|
|
2022-03-19 11:34:00 +00:00
|
|
|
|
# meson's find_library seems to not use our compiler wrapper if static parameter
|
2021-04-11 10:25:18 +00:00
|
|
|
|
# is either true/false... We work around by also providing LIBRARY_PATH
|
|
|
|
|
preConfigure = ''
|
|
|
|
|
LIBRARY_PATH=""
|
|
|
|
|
for b in ${toString (map lib.getLib buildInputs)}; do
|
|
|
|
|
if [[ -d "$b/lib" ]]; then
|
|
|
|
|
LIBRARY_PATH="$b/lib''${LIBRARY_PATH:+:}$LIBRARY_PATH"
|
|
|
|
|
fi
|
|
|
|
|
done
|
|
|
|
|
export LIBRARY_PATH
|
2022-09-17 00:00:51 +00:00
|
|
|
|
'' + lib.optionalString stdenv.isDarwin ''
|
|
|
|
|
substituteInPlace binrz/rizin/macos_sign.sh \
|
|
|
|
|
--replace 'codesign' '# codesign'
|
2021-04-11 10:25:18 +00:00
|
|
|
|
'';
|
2021-03-30 10:10:56 +00:00
|
|
|
|
|
|
|
|
|
buildInputs = [
|
|
|
|
|
file
|
|
|
|
|
libzip
|
|
|
|
|
capstone
|
|
|
|
|
readline
|
|
|
|
|
libusb-compat-0_1
|
|
|
|
|
libewf
|
|
|
|
|
perl
|
|
|
|
|
zlib
|
|
|
|
|
lz4
|
|
|
|
|
openssl
|
2023-08-05 14:11:24 +00:00
|
|
|
|
libmspack
|
2021-03-30 10:10:56 +00:00
|
|
|
|
tree-sitter
|
|
|
|
|
xxHash
|
2023-08-05 14:11:24 +00:00
|
|
|
|
xz
|
2021-03-30 10:10:56 +00:00
|
|
|
|
];
|
|
|
|
|
|
2022-10-25 16:31:45 +00:00
|
|
|
|
postPatch = ''
|
|
|
|
|
# find_installation without arguments uses Meson’s Python interpreter,
|
|
|
|
|
# which does not have any extra modules.
|
|
|
|
|
# https://github.com/mesonbuild/meson/pull/9904
|
|
|
|
|
substituteInPlace meson.build \
|
|
|
|
|
--replace "import('python').find_installation()" "find_program('python3')"
|
|
|
|
|
'';
|
|
|
|
|
|
2023-08-09 10:04:52 +00:00
|
|
|
|
passthru = rec {
|
|
|
|
|
plugins = {
|
2023-08-09 10:09:10 +00:00
|
|
|
|
jsdec = pkgs.callPackage ./jsdec.nix {
|
|
|
|
|
inherit rizin openssl;
|
|
|
|
|
};
|
2023-08-09 10:16:59 +00:00
|
|
|
|
rz-ghidra = pkgs.libsForQt5.callPackage ./rz-ghidra.nix {
|
|
|
|
|
inherit rizin openssl;
|
|
|
|
|
enableCutterPlugin = false;
|
|
|
|
|
};
|
2023-08-09 10:04:52 +00:00
|
|
|
|
# sigdb isn't a real plugin, but it's separated from the main rizin
|
|
|
|
|
# derivation so that only those who need it will download it
|
|
|
|
|
sigdb = pkgs.callPackage ./sigdb.nix { };
|
|
|
|
|
};
|
|
|
|
|
withPlugins = filter: pkgs.callPackage ./wrapper.nix {
|
2023-08-13 14:22:44 +00:00
|
|
|
|
inherit rizin;
|
2023-08-09 10:04:52 +00:00
|
|
|
|
plugins = filter plugins;
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
2021-03-30 10:10:56 +00:00
|
|
|
|
meta = {
|
|
|
|
|
description = "UNIX-like reverse engineering framework and command-line toolset.";
|
|
|
|
|
homepage = "https://rizin.re/";
|
|
|
|
|
license = lib.licenses.gpl3Plus;
|
2023-08-13 16:54:57 +00:00
|
|
|
|
mainProgram = "rizin";
|
2021-03-30 10:10:56 +00:00
|
|
|
|
maintainers = with lib.maintainers; [ raskin makefu mic92 ];
|
2022-09-17 00:00:51 +00:00
|
|
|
|
platforms = with lib.platforms; unix;
|
2021-03-30 10:10:56 +00:00
|
|
|
|
};
|
2023-08-09 10:04:52 +00:00
|
|
|
|
}; in rizin
|