nixpkgs/pkgs/development/tools/analysis/rizin/default.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

135 lines
3.3 KiB
Nix
Raw Normal View History

{ lib
, pkgs # for passthru.plugins
, stdenv
, fetchurl
, pkg-config
, libusb-compat-0_1
, readline
, libewf
, perl
, zlib
, openssl
, file
2023-08-05 14:11:24 +00:00
, libmspack
, libzip
, lz4
, xxHash
2023-08-05 14:11:24 +00:00
, xz
, meson
, python3
, cmake
, ninja
, capstone
, tree-sitter
}:
let rizin = stdenv.mkDerivation rec {
pname = "rizin";
2023-09-17 08:29:38 +00:00
version = "0.6.2";
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=";
};
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"
# this is needed for wrapping (adding plugins) to work
"-Dportable=true"
];
# 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
(python3.withPackages (pp: with pp; [
pyyaml
]))
2022-09-16 21:44:36 +00:00
ninja
cmake
];
2021-04-11 10:25:18 +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
'';
buildInputs = [
file
libzip
capstone
readline
libusb-compat-0_1
libewf
perl
zlib
lz4
openssl
2023-08-05 14:11:24 +00:00
libmspack
tree-sitter
xxHash
2023-08-05 14:11:24 +00:00
xz
];
postPatch = ''
# find_installation without arguments uses Mesons 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')"
'';
passthru = rec {
plugins = {
2023-08-09 10:09:10 +00:00
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;
};
};
meta = {
description = "UNIX-like reverse engineering framework and command-line toolset.";
homepage = "https://rizin.re/";
license = lib.licenses.gpl3Plus;
mainProgram = "rizin";
maintainers = with lib.maintainers; [ raskin makefu mic92 ];
2022-09-17 00:00:51 +00:00
platforms = with lib.platforms; unix;
};
}; in rizin