diff options
| -rw-r--r-- | flake.nix | 2 | ||||
| -rw-r--r-- | modules/common.nix | 8 | ||||
| -rw-r--r-- | pkgs/default.nix | 4 | ||||
| -rw-r--r-- | pkgs/ghidra/default.nix | 87 |
4 files changed, 85 insertions, 16 deletions
diff --git a/flake.nix b/flake.nix index fbfcc30..ca3e1c5 100644 --- a/flake.nix +++ b/flake.nix @@ -72,7 +72,7 @@ unstablePkgs = import nixpkgs-unstable commonPkgsInputs; - auxiliaryPkgs = import ./pkgs { inherit pkgs unstablePkgs; }; + auxiliaryPkgs = import ./pkgs { inherit pkgs unstablePkgs nixpkgs nixpkgs-unstable; }; }; in diff --git a/modules/common.nix b/modules/common.nix index 22102f9..bcfbff5 100644 --- a/modules/common.nix +++ b/modules/common.nix @@ -66,6 +66,12 @@ fish.enable = true; git.enable = true; + ghidra = { + enable = true; + package = auxiliaryPkgs.ghidra; + gdb = true; + }; + adb.enable = true; gnupg.agent = { @@ -121,7 +127,7 @@ man-pages man-pages-posix ]) ++ (with auxiliaryPkgs; [ # TODO: need fixes for 25.05 - # ghidra retroarch wine + # retroarch wine ngfx ]); 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 + ] +) |
