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