2021-04-08 16:26:57 +00:00
|
|
|
|
{ lib
|
2023-08-22 20:05:09 +00:00
|
|
|
|
, pkgs # for passthru.plugins
|
2021-04-08 16:26:57 +00:00
|
|
|
|
, stdenv
|
|
|
|
|
, fetchurl
|
|
|
|
|
, pkg-config
|
|
|
|
|
, libusb-compat-0_1
|
|
|
|
|
, readline
|
|
|
|
|
, libewf
|
|
|
|
|
, perl
|
|
|
|
|
, zlib
|
|
|
|
|
, openssl
|
|
|
|
|
, file
|
2023-08-10 07:59:29 +00:00
|
|
|
|
, libmspack
|
2021-04-08 16:26:57 +00:00
|
|
|
|
, libzip
|
|
|
|
|
, lz4
|
|
|
|
|
, xxHash
|
2023-08-10 07:59:29 +00:00
|
|
|
|
, xz
|
2021-04-08 16:26:57 +00:00
|
|
|
|
, meson
|
2022-10-30 15:09:59 +00:00
|
|
|
|
, python3
|
2021-04-08 16:26:57 +00:00
|
|
|
|
, cmake
|
|
|
|
|
, ninja
|
|
|
|
|
, capstone
|
|
|
|
|
, tree-sitter
|
|
|
|
|
}:
|
|
|
|
|
|
2023-08-22 20:05:09 +00:00
|
|
|
|
let rizin = stdenv.mkDerivation rec {
|
2021-04-08 16:26:57 +00:00
|
|
|
|
pname = "rizin";
|
2023-10-09 19:29:22 +00:00
|
|
|
|
version = "0.6.2";
|
2021-04-08 16:26:57 +00:00
|
|
|
|
|
|
|
|
|
src = fetchurl {
|
2021-04-12 18:23:04 +00:00
|
|
|
|
url = "https://github.com/rizinorg/rizin/releases/download/v${version}/rizin-src-v${version}.tar.xz";
|
2023-10-09 19:29:22 +00:00
|
|
|
|
hash = "sha256-4poAo+IgBL3RAUbShrHM4OBhltQarkcpqvydeDIf+Gs=";
|
2021-04-08 16:26:57 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
mesonFlags = [
|
2021-04-12 18:23:04 +00:00
|
|
|
|
"-Duse_sys_capstone=enabled"
|
|
|
|
|
"-Duse_sys_magic=enabled"
|
|
|
|
|
"-Duse_sys_libzip=enabled"
|
|
|
|
|
"-Duse_sys_zlib=enabled"
|
|
|
|
|
"-Duse_sys_lz4=enabled"
|
2023-08-10 07:59:29 +00:00
|
|
|
|
"-Duse_sys_lzma=enabled"
|
|
|
|
|
"-Duse_sys_xxhash=enabled"
|
2021-04-12 18:23:04 +00:00
|
|
|
|
"-Duse_sys_openssl=enabled"
|
2023-08-10 07:59:29 +00:00
|
|
|
|
"-Duse_sys_libmspack=enabled"
|
2021-04-12 18:23:04 +00:00
|
|
|
|
"-Duse_sys_tree_sitter=enabled"
|
2023-08-22 20:05:09 +00:00
|
|
|
|
# this is needed for wrapping (adding plugins) to work
|
|
|
|
|
"-Dportable=true"
|
2021-04-08 16:26:57 +00:00
|
|
|
|
];
|
|
|
|
|
|
2023-08-22 20:05:09 +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-22 12:36:57 +00:00
|
|
|
|
nativeBuildInputs = [
|
|
|
|
|
pkg-config
|
|
|
|
|
meson
|
2022-10-30 15:09:59 +00:00
|
|
|
|
(python3.withPackages (pp: with pp; [
|
|
|
|
|
pyyaml
|
|
|
|
|
]))
|
2022-09-22 12:36:57 +00:00
|
|
|
|
ninja
|
|
|
|
|
cmake
|
|
|
|
|
];
|
2021-04-12 18:23:04 +00:00
|
|
|
|
|
2022-03-30 09:31:56 +00:00
|
|
|
|
# meson's find_library seems to not use our compiler wrapper if static parameter
|
2021-04-12 18:23:04 +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-22 12:36:57 +00:00
|
|
|
|
'' + lib.optionalString stdenv.isDarwin ''
|
|
|
|
|
substituteInPlace binrz/rizin/macos_sign.sh \
|
|
|
|
|
--replace 'codesign' '# codesign'
|
2021-04-12 18:23:04 +00:00
|
|
|
|
'';
|
2021-04-08 16:26:57 +00:00
|
|
|
|
|
|
|
|
|
buildInputs = [
|
|
|
|
|
file
|
|
|
|
|
libzip
|
|
|
|
|
capstone
|
|
|
|
|
readline
|
|
|
|
|
libusb-compat-0_1
|
|
|
|
|
libewf
|
|
|
|
|
perl
|
|
|
|
|
zlib
|
|
|
|
|
lz4
|
|
|
|
|
openssl
|
2023-08-10 07:59:29 +00:00
|
|
|
|
libmspack
|
2021-04-08 16:26:57 +00:00
|
|
|
|
tree-sitter
|
|
|
|
|
xxHash
|
2023-08-10 07:59:29 +00:00
|
|
|
|
xz
|
2021-04-08 16:26:57 +00:00
|
|
|
|
];
|
|
|
|
|
|
2022-10-30 15:09:59 +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-22 20:05:09 +00:00
|
|
|
|
passthru = rec {
|
|
|
|
|
plugins = {
|
|
|
|
|
jsdec = pkgs.callPackage ./jsdec.nix {
|
|
|
|
|
inherit rizin openssl;
|
|
|
|
|
};
|
|
|
|
|
rz-ghidra = pkgs.libsForQt5.callPackage ./rz-ghidra.nix {
|
|
|
|
|
inherit rizin openssl;
|
|
|
|
|
enableCutterPlugin = false;
|
|
|
|
|
};
|
|
|
|
|
# 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 {
|
|
|
|
|
inherit rizin;
|
|
|
|
|
plugins = filter plugins;
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
2021-04-08 16:26:57 +00:00
|
|
|
|
meta = {
|
|
|
|
|
description = "UNIX-like reverse engineering framework and command-line toolset.";
|
|
|
|
|
homepage = "https://rizin.re/";
|
|
|
|
|
license = lib.licenses.gpl3Plus;
|
2023-08-22 20:05:09 +00:00
|
|
|
|
mainProgram = "rizin";
|
2021-04-08 16:26:57 +00:00
|
|
|
|
maintainers = with lib.maintainers; [ raskin makefu mic92 ];
|
2022-09-22 12:36:57 +00:00
|
|
|
|
platforms = with lib.platforms; unix;
|
2021-04-08 16:26:57 +00:00
|
|
|
|
};
|
2023-08-22 20:05:09 +00:00
|
|
|
|
}; in rizin
|