diff options
Diffstat (limited to 'pkgs/ghidra/default.nix')
| -rw-r--r-- | pkgs/ghidra/default.nix | 87 |
1 files changed, 75 insertions, 12 deletions
diff --git a/pkgs/ghidra/default.nix b/pkgs/ghidra/default.nix index 79e61e5..56045b1 100644 --- a/pkgs/ghidra/default.nix +++ b/pkgs/ghidra/default.nix @@ -1,15 +1,78 @@ -{ ghidra }: +{ + lib, + ghidra, + openjdk21, + nixpkgs, + makeWrapper, + runCommand, + callPackage, + ... +}: let - ghidra-patched = ghidra.overrideAttrs (finalAttrs: previousAttrs: { - patches = previousAttrs.patches ++ [ ./ui-scale.patch ]; - }); + ghidra-copy = let + copy = runCommand "ghidra-patched" { + nativeBuildInputs = [ makeWrapper ]; + } '' + mkdir -p $out $out/lib/ghidra/support + + # dont let `cp` overwrite this later + ln -s \ + $out/lib/ghidra/support/.launch.sh-wrapped \ + $out/lib/ghidra/support/launch.sh + + patch \ + ${ghidra}/lib/ghidra/support/launch.properties \ + -i ${./ui-scale.patch} \ + -o $out/lib/ghidra/support/launch.properties + + cp --update=none -r ${ghidra}/bin ${ghidra}/lib ${ghidra}/share $out/ + + # the original has references to the old ghidra package + wrapProgram "$out/lib/ghidra/support/.launch.sh-wrapped" \ + --set-default NIX_GHIDRAHOME "$out/lib/ghidra/Ghidra" \ + --prefix PATH : ${lib.makeBinPath [ openjdk21 ]} + ''; + in + copy + // { inherit (ghidra) pname version meta releaseName distroPrefix; }; + + members = + let + # a bit spooky, no? :3 + nixGhidraPath = "${nixpkgs}/pkgs/tools/security/ghidra"; + + buildExtensionAndScripts = callPackage "${nixGhidraPath}/build-extension.nix" { + ghidra = ghidra-patched; + }; + + withExtensions = callPackage "${nixGhidraPath}/with-extensions.nix" { + ghidra = ghidra-patched; + }; + + extensions = callPackage "${nixGhidraPath}/extensions.nix" { + inherit ghidra; + }; + in + { + inherit withExtensions extensions; + inherit (buildExtensionAndScripts) buildExtension buildGhidraScripts; + }; + + ghidra-patched = ghidra-copy // members; in -ghidra-patched.withExtensions (extensions: with extensions; [ - gnudisassembler - machinelearning - ghidraninja-ghidra-scripts - lightkeeper - ret-sync - ghidra-delinker-extension -]) +ghidra-patched.withExtensions ( + # extensions passed by function are not built correctly, + # use extensions build with "normal" ghidra. + extensions: with members.extensions; [ + gnudisassembler + machinelearning + ghidraninja-ghidra-scripts + wasm + lightkeeper + kaiju + ret-sync + ghidra-delinker-extension + ghidra-golanganalyzerextension + ] +) |
