1{
2 lib,
3 makeWrapper,
4 symlinkJoin,
5 plugins,
6 rizin,
7 isCutter ? false,
8 cutter,
9}:
10
11let
12 unwrapped = if isCutter then cutter else rizin;
13in
14symlinkJoin {
15 name = "${unwrapped.pname}-with-plugins-${unwrapped.version}";
16
17 # NIX_RZ_PREFIX only changes where *Rizin* locates files (plugins,
18 # themes, etc). But we must change it even for wrapping Cutter, because
19 # Cutter plugins often have associated Rizin plugins. This means that
20 # $out (which NIX_RZ_PREFIX will be set to) must always contain Rizin
21 # files, even if we only wrap Cutter - so for Cutter, include Rizin to
22 # symlinkJoin paths.
23 paths = [ unwrapped ] ++ lib.optional isCutter rizin ++ plugins;
24
25 nativeBuildInputs = [ makeWrapper ];
26
27 passthru = {
28 inherit unwrapped;
29 };
30
31 postBuild = ''
32 rm $out/bin/*
33 wrapperArgs=(--set NIX_RZ_PREFIX $out${lib.optionalString isCutter " --prefix XDG_DATA_DIRS : $out/share"})
34 for binary in $(ls ${unwrapped}/bin); do
35 makeWrapper ${unwrapped}/bin/$binary $out/bin/$binary "''${wrapperArgs[@]}"
36 done
37 '';
38
39 meta = unwrapped.meta // {
40 # prefer wrapped over unwrapped
41 priority = (unwrapped.meta.priority or lib.meta.defaultPriority) - 1;
42 };
43}