nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 stdenv,
3 fetchzip,
4 lib,
5 makeWrapper,
6 autoPatchelfHook,
7 openjdk21,
8 pam,
9 makeDesktopItem,
10 icoutils,
11}:
12
13let
14
15 pkg_path = "$out/lib/ghidra";
16
17 desktopItem = makeDesktopItem {
18 name = "ghidra";
19 exec = "ghidra";
20 icon = "ghidra";
21 desktopName = "Ghidra";
22 genericName = "Ghidra Software Reverse Engineering Suite";
23 categories = [ "Development" ];
24 terminal = false;
25 startupWMClass = "ghidra-Ghidra";
26 };
27
28in
29stdenv.mkDerivation rec {
30 pname = "ghidra";
31 version = "11.3.2";
32 versiondate = "20250415";
33
34 src = fetchzip {
35 url = "https://github.com/NationalSecurityAgency/ghidra/releases/download/Ghidra_${version}_build/ghidra_${version}_PUBLIC_${versiondate}.zip";
36 hash = "sha256-97L3BueekbZfFAdiLX1DHlVSzNyspu4exafpFVraMWE=";
37 };
38
39 nativeBuildInputs = [
40 makeWrapper
41 icoutils
42 ]
43 ++ lib.optionals stdenv.hostPlatform.isLinux [ autoPatchelfHook ];
44
45 buildInputs = [
46 (lib.getLib stdenv.cc.cc)
47 pam
48 ];
49
50 dontStrip = true;
51
52 installPhase = ''
53 mkdir -p "${pkg_path}"
54 mkdir -p "${pkg_path}" "$out/share/applications"
55 cp -a * "${pkg_path}"
56 ln -s ${desktopItem}/share/applications/* $out/share/applications
57
58 icotool -x "${pkg_path}/support/ghidra.ico"
59 rm ghidra_4_40x40x32.png
60 for f in ghidra_*.png; do
61 res=$(basename "$f" ".png" | cut -d"_" -f3 | cut -d"x" -f1-2)
62 mkdir -pv "$out/share/icons/hicolor/$res/apps"
63 mv "$f" "$out/share/icons/hicolor/$res/apps/ghidra.png"
64 done;
65 '';
66
67 postFixup = ''
68 mkdir -p "$out/bin"
69 ln -s "${pkg_path}/ghidraRun" "$out/bin/ghidra"
70 ln -s "${pkg_path}/support/analyzeHeadless" "$out/bin/ghidra-analyzeHeadless"
71
72 wrapProgram "${pkg_path}/support/launch.sh" \
73 --prefix PATH : ${lib.makeBinPath [ openjdk21 ]}
74 '';
75
76 meta = with lib; {
77 description = "Software reverse engineering (SRE) suite of tools developed by NSA's Research Directorate in support of the Cybersecurity mission";
78 mainProgram = "ghidra";
79 homepage = "https://github.com/NationalSecurityAgency/ghidra";
80 platforms = [
81 "x86_64-linux"
82 "aarch64-linux"
83 "x86_64-darwin"
84 "aarch64-darwin"
85 ];
86 sourceProvenance = with sourceTypes; [ binaryBytecode ];
87 license = licenses.asl20;
88 maintainers = with maintainers; [
89 ck3d
90 govanify
91 mic92
92 ];
93 };
94
95}