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