diff options
| author | Mel <mel@rnrd.eu> | 2025-06-20 00:13:53 +0200 |
|---|---|---|
| committer | Mel <mel@rnrd.eu> | 2025-06-20 00:13:53 +0200 |
| commit | a4fe78dc26cce857b3028d9edb90737bdc6677c6 (patch) | |
| tree | fb2c742346544179f11c6851ed13a3b9f2f3ead3 /pkgs | |
| parent | e03f74bfdc3bde6fbd9e32497015c09c6c577fba (diff) | |
| download | minerals-a4fe78dc26cce857b3028d9edb90737bdc6677c6.tar.zst minerals-a4fe78dc26cce857b3028d9edb90737bdc6677c6.zip | |
Patch Ghidra without rebuild
Signed-off-by: Mel <mel@rnrd.eu>
Diffstat (limited to 'pkgs')
| -rw-r--r-- | pkgs/default.nix | 4 | ||||
| -rw-r--r-- | pkgs/ghidra/default.nix | 87 |
2 files changed, 77 insertions, 14 deletions
diff --git a/pkgs/default.nix b/pkgs/default.nix index ddaf684..eeeb5a7 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -1,4 +1,4 @@ -{ pkgs, unstablePkgs, ... }: +{ pkgs, unstablePkgs, nixpkgs, nixpkgs-unstable, ... }: { inherit (pkgs.callPackages ./electron-wayland-wrappers.nix { }) @@ -7,7 +7,7 @@ element-desktop ; - ghidra = unstablePkgs.callPackage ./ghidra { }; + ghidra = pkgs.callPackage ./ghidra { inherit nixpkgs; }; ngfx = pkgs.callPackage ./ngfx.nix { }; 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 + ] +) |
