summaryrefslogtreecommitdiff
path: root/pkgs/ghidra
diff options
context:
space:
mode:
authorMel <mel@rnrd.eu>2025-06-20 00:13:53 +0200
committerMel <mel@rnrd.eu>2025-06-20 00:13:53 +0200
commita4fe78dc26cce857b3028d9edb90737bdc6677c6 (patch)
treefb2c742346544179f11c6851ed13a3b9f2f3ead3 /pkgs/ghidra
parente03f74bfdc3bde6fbd9e32497015c09c6c577fba (diff)
downloadminerals-a4fe78dc26cce857b3028d9edb90737bdc6677c6.tar.zst
minerals-a4fe78dc26cce857b3028d9edb90737bdc6677c6.zip
Patch Ghidra without rebuild
Signed-off-by: Mel <mel@rnrd.eu>
Diffstat (limited to 'pkgs/ghidra')
-rw-r--r--pkgs/ghidra/default.nix87
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
+ ]
+)