blob: 56045b1912f0b74f7b805d3f497687e3a0d8c68e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
{
lib,
ghidra,
openjdk21,
nixpkgs,
makeWrapper,
runCommand,
callPackage,
...
}:
let
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 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
]
)
|