2023-08-09 12:04:52 +02:00
|
|
|
{ lib
|
|
|
|
, makeWrapper
|
|
|
|
, symlinkJoin
|
|
|
|
, plugins
|
2023-08-13 16:22:44 +02:00
|
|
|
, rizin
|
|
|
|
, isCutter ? false
|
|
|
|
, cutter
|
2023-08-09 12:04:52 +02:00
|
|
|
}:
|
|
|
|
|
2023-08-13 16:22:44 +02:00
|
|
|
let
|
|
|
|
unwrapped = if isCutter then cutter else rizin;
|
|
|
|
in
|
2023-08-09 12:04:52 +02:00
|
|
|
symlinkJoin {
|
|
|
|
name = "${unwrapped.pname}-with-plugins-${unwrapped.version}";
|
|
|
|
|
2023-08-13 16:22:44 +02:00
|
|
|
# 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;
|
2023-08-09 12:04:52 +02:00
|
|
|
|
|
|
|
nativeBuildInputs = [ makeWrapper ];
|
|
|
|
|
|
|
|
passthru = {
|
|
|
|
inherit unwrapped;
|
|
|
|
};
|
|
|
|
|
|
|
|
postBuild = ''
|
|
|
|
rm $out/bin/*
|
2023-08-13 16:22:44 +02:00
|
|
|
wrapperArgs=(--set NIX_RZ_PREFIX $out${
|
|
|
|
lib.optionalString isCutter " --prefix XDG_DATA_DIRS : $out/share"
|
|
|
|
})
|
2023-08-09 12:04:52 +02:00
|
|
|
for binary in $(ls ${unwrapped}/bin); do
|
|
|
|
makeWrapper ${unwrapped}/bin/$binary $out/bin/$binary "''${wrapperArgs[@]}"
|
|
|
|
done
|
|
|
|
'';
|
|
|
|
|
|
|
|
meta = unwrapped.meta // {
|
2023-08-13 16:22:44 +02:00
|
|
|
# prefer wrapped over unwrapped
|
|
|
|
priority = (unwrapped.meta.priority or 0) - 1;
|
2023-08-09 12:04:52 +02:00
|
|
|
};
|
|
|
|
}
|