Compare commits

...

2 commits

Author SHA1 Message Date
bad
f690335d83 Format nixpkgs 2022-08-02 19:15:07 +02:00
bad
3f91ac23a0 Use a portable rizin binary instead of wrapping all the libraries 2022-08-02 19:14:55 +02:00
4 changed files with 27 additions and 28 deletions

View file

@ -7,7 +7,9 @@
outputs = { self, nixpkgs, flake-utils }: outputs = { self, nixpkgs, flake-utils }:
{ {
overlays.default = final: prev: { overlays.default = final: prev: {
rizin-unwrapped = prev.rizin; rizin-unwrapped = prev.rizin.overrideAttrs (o: {
mesonFlags = o.mesonFlags ++ [ "-Dportable=true" ];
});
rizin = self.packages.${prev.system}.rizin; rizin = self.packages.${prev.system}.rizin;
rizinPlugins = { rizinPlugins = {
rz-ghidra = self.packages.${prev.system}.rz-ghidra; rz-ghidra = self.packages.${prev.system}.rz-ghidra;
@ -26,6 +28,7 @@
in in
rec { rec {
packages = flake-utils.lib.flattenTree { packages = flake-utils.lib.flattenTree {
rizin-unwrapped = pkgs.rizin-unwrapped;
rizin = pkgs.callPackage ./rizin-with-plugin-support.nix { }; rizin = pkgs.callPackage ./rizin-with-plugin-support.nix { };
rz-ghidra = pkgs.callPackage ./rz-ghidra.nix { }; rz-ghidra = pkgs.callPackage ./rz-ghidra.nix { };
jsdec = pkgs.callPackage ./jsdec.nix { }; jsdec = pkgs.callPackage ./jsdec.nix { };

View file

@ -1,4 +1,4 @@
{ lib, stdenv, fetchFromGitHub, meson, pkg-config, cmake, ninja, openssl, rizin }: stdenv.mkDerivation { { lib, stdenv, fetchFromGitHub, meson, pkg-config, cmake, ninja, openssl, rizin-unwrapped }: stdenv.mkDerivation {
name = "jsdec"; name = "jsdec";
src = fetchFromGitHub { src = fetchFromGitHub {
owner = "rizinorg"; owner = "rizinorg";
@ -10,6 +10,6 @@
cd p cd p
''; '';
mesonFlags = [ "-Djsc_folder=/build/source/" ]; mesonFlags = [ "-Djsc_folder=/build/source/" ];
buildInputs = [ rizin openssl ]; buildInputs = [ rizin-unwrapped openssl ];
nativeBuildInputs = [ meson pkg-config ninja ]; nativeBuildInputs = [ meson pkg-config ninja ];
} }

View file

@ -1,27 +1,23 @@
{ rizin-unwrapped, rizinPlugins, makeWrapper, symlinkJoin }: { rizin-unwrapped, rizinPlugins, symlinkJoin }:
let let
makeRizinPackageWithPlugins = plugins: makeRizinPackageWithPlugins = plugins:
let symlinkJoin
plugins_path = symlinkJoin { {
name = "rizin-plugins"; name = "rizin";
paths = plugins; paths = [ rizin-unwrapped ] ++ plugins;
}; postBuild = ''
in cd $out/bin/
symlinkJoin { for file in ./*; do
name = "rizin"; # Rizin loads plugins from a path relative to /proc/self/exe.
paths = [ rizin-unwrapped ]; # /proc/self/exe resolves symlinks so we need to copy the resulting binary.
buildInputs = [makeWrapper]; # This is obviously not ideal, but the binaries weight only a few kibibytes
postBuild = '' # and nix can replace the copy with a hardlink automatically, via nix store optimize
wrapProgramArgs=()
for plugin in ${plugins_path}/lib/rizin/plugins/*; do cp --remove-destination "$(readlink "$file")" "$file"
wrapProgramArgs+=("--add-flags") done
wrapProgramArgs+=("-l") '';
wrapProgramArgs+=("--add-flags") } // {
wrapProgramArgs+=("$plugin")
done
wrapProgram $out/bin/rizin ''${wrapProgramArgs[*]}
'';
} // {
withPlugins = p: makeRizinPackageWithPlugins (plugins ++ (p rizinPlugins)); withPlugins = p: makeRizinPackageWithPlugins (plugins ++ (p rizinPlugins));
}; };
in makeRizinPackageWithPlugins [] in
makeRizinPackageWithPlugins [ ]

View file

@ -1,4 +1,4 @@
{ lib, stdenv, fetchgit, pkg-config, cmake, openssl, rizin }: stdenv.mkDerivation { { lib, stdenv, fetchgit, pkg-config, cmake, openssl, rizin-unwrapped }: stdenv.mkDerivation {
name = "rz-ghidra"; name = "rz-ghidra";
src = fetchgit { src = fetchgit {
url = "https://github.com/rizinorg/rz-ghidra.git"; url = "https://github.com/rizinorg/rz-ghidra.git";
@ -7,6 +7,6 @@
fetchSubmodules = true; fetchSubmodules = true;
}; };
mesonFlags = [ "-Djsc_folder=.." ]; mesonFlags = [ "-Djsc_folder=.." ];
buildInputs = [ rizin cmake openssl ]; buildInputs = [ rizin-unwrapped cmake openssl ];
nativeBuildInputs = [ pkg-config ]; nativeBuildInputs = [ pkg-config ];
} }