From 2fb2f3994dec6be6196520cededa2c569b2cffa5 Mon Sep 17 00:00:00 2001 From: chayleaf Date: Sun, 13 Aug 2023 21:22:44 +0700 Subject: [PATCH] rizin: wrapper fixes 1. Set cutterPlugins to cutter.plugins rather than rizin.plugins which it was set to by mistake 2. Remove Rizin binaries from Cutter wrapper, because they aren't actually used by Cutter and if the user needs those binaries they should install Rizin separately --- .../tools/analysis/rizin/cutter.nix | 4 +- .../tools/analysis/rizin/default.nix | 2 +- .../tools/analysis/rizin/wrapper.nix | 38 +++++++++---------- pkgs/top-level/all-packages.nix | 2 +- 4 files changed, 22 insertions(+), 24 deletions(-) diff --git a/pkgs/development/tools/analysis/rizin/cutter.nix b/pkgs/development/tools/analysis/rizin/cutter.nix index bb8ecb6e196a..a74e432f2c18 100644 --- a/pkgs/development/tools/analysis/rizin/cutter.nix +++ b/pkgs/development/tools/analysis/rizin/cutter.nix @@ -47,8 +47,8 @@ let cutter = mkDerivation rec { }; }; withPlugins = filter: pkgs.callPackage ./wrapper.nix { - unwrapped = cutter; - inherit rizin; + inherit rizin cutter; + isCutter = true; plugins = filter plugins; }; }; diff --git a/pkgs/development/tools/analysis/rizin/default.nix b/pkgs/development/tools/analysis/rizin/default.nix index 46fe132a463e..f6574afb6cf7 100644 --- a/pkgs/development/tools/analysis/rizin/default.nix +++ b/pkgs/development/tools/analysis/rizin/default.nix @@ -118,7 +118,7 @@ let rizin = stdenv.mkDerivation rec { sigdb = pkgs.callPackage ./sigdb.nix { }; }; withPlugins = filter: pkgs.callPackage ./wrapper.nix { - unwrapped = rizin; + inherit rizin; plugins = filter plugins; }; }; diff --git a/pkgs/development/tools/analysis/rizin/wrapper.nix b/pkgs/development/tools/analysis/rizin/wrapper.nix index 5ddee52f2324..11d046c27f6d 100644 --- a/pkgs/development/tools/analysis/rizin/wrapper.nix +++ b/pkgs/development/tools/analysis/rizin/wrapper.nix @@ -1,20 +1,25 @@ { lib , makeWrapper , symlinkJoin -, unwrapped , plugins -# NIX_RZ_PREFIX only changes where *Rizin* locates files (plugins, -# themes, etc). But we must change it even for wrapping Cutter, because -# Cutter plugins often have associated Rizin plugins. This means that -# NIX_RZ_PREFIX must always contain Rizin files, even if we only wrap -# Cutter - so for Cutter, include Rizin to symlinkJoin paths. -, rizin ? null +, rizin +, isCutter ? false +, cutter }: +let + unwrapped = if isCutter then cutter else rizin; +in symlinkJoin { name = "${unwrapped.pname}-with-plugins-${unwrapped.version}"; - paths = [ unwrapped ] ++ lib.optional (rizin != null) rizin ++ plugins; + # NIX_RZ_PREFIX only changes where *Rizin* locates files (plugins, + # themes, etc). But we must change it even for wrapping Cutter, because + # Cutter plugins often have associated Rizin plugins. This means that + # $out (which NIX_RZ_PREFIX will be set to) must always contain Rizin + # files, even if we only wrap Cutter - so for Cutter, include Rizin to + # symlinkJoin paths. + paths = [ unwrapped ] ++ lib.optional isCutter rizin ++ plugins; nativeBuildInputs = [ makeWrapper ]; @@ -24,23 +29,16 @@ symlinkJoin { postBuild = '' rm $out/bin/* - wrapperArgs=(--set NIX_RZ_PREFIX $out) - if [ -d $out/share/rizin/cutter ]; then - wrapperArgs+=(--prefix XDG_DATA_DIRS : $out/share) - fi + wrapperArgs=(--set NIX_RZ_PREFIX $out${ + lib.optionalString isCutter " --prefix XDG_DATA_DIRS : $out/share" + }) for binary in $(ls ${unwrapped}/bin); do makeWrapper ${unwrapped}/bin/$binary $out/bin/$binary "''${wrapperArgs[@]}" done - ${lib.optionalString (rizin != null) '' - for binary in $(ls ${rizin}/bin); do - makeWrapper ${rizin}/bin/$binary $out/bin/$binary "''${wrapperArgs[@]}" - done - ''} ''; meta = unwrapped.meta // { - # prefer wrapped over unwrapped, prefer cutter wrapper over rizin wrapper - # (because cutter versions of plugins also contain rizin plugins) - priority = (unwrapped.meta.priority or 0) - (if rizin != null then 2 else 1); + # prefer wrapped over unwrapped + priority = (unwrapped.meta.priority or 0) - 1; }; } diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 66336279eb92..9942cd0dc795 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -19802,7 +19802,7 @@ with pkgs; cutter = libsForQt5.callPackage ../development/tools/analysis/rizin/cutter.nix { }; - cutterPlugins = recurseIntoAttrs rizin.plugins; + cutterPlugins = recurseIntoAttrs cutter.plugins; ragel = ragelStable;