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 ] ++ lib.optionals stdenv.hostPlatform.isLinux [ autoPatchelfHook ];
43
44 buildInputs = [
45 (lib.getLib stdenv.cc.cc)
46 pam
47 ];
48
49 dontStrip = true;
50
51 installPhase = ''
52 mkdir -p "${pkg_path}"
53 mkdir -p "${pkg_path}" "$out/share/applications"
54 cp -a * "${pkg_path}"
55 ln -s ${desktopItem}/share/applications/* $out/share/applications
56
57 icotool -x "${pkg_path}/support/ghidra.ico"
58 rm ghidra_4_40x40x32.png
59 for f in ghidra_*.png; do
60 res=$(basename "$f" ".png" | cut -d"_" -f3 | cut -d"x" -f1-2)
61 mkdir -pv "$out/share/icons/hicolor/$res/apps"
62 mv "$f" "$out/share/icons/hicolor/$res/apps/ghidra.png"
63 done;
64 '';
65
66 postFixup = ''
67 mkdir -p "$out/bin"
68 ln -s "${pkg_path}/ghidraRun" "$out/bin/ghidra"
69 ln -s "${pkg_path}/support/analyzeHeadless" "$out/bin/ghidra-analyzeHeadless"
70
71 wrapProgram "${pkg_path}/support/launch.sh" \
72 --prefix PATH : ${lib.makeBinPath [ openjdk21 ]}
73 '';
74
75 meta = with lib; {
76 description = "Software reverse engineering (SRE) suite of tools developed by NSA's Research Directorate in support of the Cybersecurity mission";
77 mainProgram = "ghidra";
78 homepage = "https://github.com/NationalSecurityAgency/ghidra";
79 platforms = [
80 "x86_64-linux"
81 "aarch64-linux"
82 "x86_64-darwin"
83 "aarch64-darwin"
84 ];
85 sourceProvenance = with sourceTypes; [ binaryBytecode ];
86 license = licenses.asl20;
87 maintainers = with maintainers; [
88 ck3d
89 govanify
90 mic92
91 ];
92 };
93
94}