fdb820602b
To reproduce:
$ nix run nixpkgs/3b32825de172d0bc85664f495edb096b10862524#ast-grep \
-- scan --update-all --inline-rules '
id: nix-x86_64-darwin
language: nix
rule:
any:
- pattern: "\"x86_64-darwin\""
kind: list_expression > string_expression
- pattern:
context: "{ \"x86_64-darwin\" = $EXPR; }"
selector: binding
- pattern:
context: "{ x86_64-darwin = $EXPR; }"
selector: binding
fix:
template: ""
' pkgs
$ nix run nixpkgs/3b32825de172d0bc85664f495edb096b10862524#ast-grep \
-- scan --update-all --inline-rules '
id: json-first-x86_64-darwin
language: json
rule:
kind: object > pair:nth-child(1)
has:
pattern: "\"x86_64-darwin\""
field: key
fix:
template: ""
expandEnd: { regex: "," }
' pkgs
$ nix run nixpkgs/3b32825de172d0bc85664f495edb096b10862524#ast-grep \
-- scan --update-all --inline-rules '
id: json-x86_64-darwin
language: json
rule:
kind: object > pair
has:
pattern: "\"x86_64-darwin\""
field: key
fix:
template: ""
expandStart: { regex: "," }
' pkgs
$ git restore pkgs/by-name/om/omnix/package.nix
$ git diff --name-only -z \
| nix shell nixpkgs/3b32825de172d0bc85664f495edb096b10862524#gnused \
-c xargs -0 sed -i '/^$/N; /^\n\? \+$/d'
$ treefmt
95 lines
2.3 KiB
Nix
95 lines
2.3 KiB
Nix
{
|
|
stdenv,
|
|
fetchzip,
|
|
lib,
|
|
makeWrapper,
|
|
autoPatchelfHook,
|
|
openjdk21,
|
|
pam,
|
|
makeDesktopItem,
|
|
icoutils,
|
|
}:
|
|
|
|
let
|
|
|
|
pkg_path = "$out/lib/ghidra";
|
|
|
|
desktopItem = makeDesktopItem {
|
|
name = "ghidra";
|
|
exec = "ghidra";
|
|
icon = "ghidra";
|
|
desktopName = "Ghidra";
|
|
genericName = "Ghidra Software Reverse Engineering Suite";
|
|
categories = [ "Development" ];
|
|
terminal = false;
|
|
startupWMClass = "ghidra-Ghidra";
|
|
};
|
|
|
|
in
|
|
stdenv.mkDerivation rec {
|
|
pname = "ghidra";
|
|
version = "12.1.2";
|
|
versiondate = "20260605";
|
|
src = fetchzip {
|
|
url = "https://github.com/NationalSecurityAgency/ghidra/releases/download/Ghidra_${version}_build/ghidra_${version}_PUBLIC_${versiondate}.zip";
|
|
hash = "sha256-ulIBecjWAnrM8iJmqQZAZRerUCKpIBcXyv6KIB7I/ZA=";
|
|
};
|
|
|
|
nativeBuildInputs = [
|
|
makeWrapper
|
|
icoutils
|
|
]
|
|
++ lib.optionals stdenv.hostPlatform.isLinux [ autoPatchelfHook ];
|
|
|
|
buildInputs = [
|
|
(lib.getLib stdenv.cc.cc)
|
|
pam
|
|
];
|
|
|
|
dontStrip = true;
|
|
|
|
installPhase = ''
|
|
mkdir -p "${pkg_path}"
|
|
mkdir -p "${pkg_path}" "$out/share/applications"
|
|
cp -a * "${pkg_path}"
|
|
ln -s ${desktopItem}/share/applications/* $out/share/applications
|
|
|
|
icotool -x "${pkg_path}/support/ghidra.ico"
|
|
rm ghidra_4_40x40x32.png
|
|
for f in ghidra_*.png; do
|
|
res=$(basename "$f" ".png" | cut -d"_" -f3 | cut -d"x" -f1-2)
|
|
mkdir -pv "$out/share/icons/hicolor/$res/apps"
|
|
mv "$f" "$out/share/icons/hicolor/$res/apps/ghidra.png"
|
|
done;
|
|
'';
|
|
|
|
postFixup = ''
|
|
mkdir -p "$out/bin"
|
|
ln -s "${pkg_path}/ghidraRun" "$out/bin/ghidra"
|
|
ln -s "${pkg_path}/support/analyzeHeadless" "$out/bin/ghidra-analyzeHeadless"
|
|
|
|
wrapProgram "${pkg_path}/support/launch.sh" \
|
|
--prefix PATH : ${lib.makeBinPath [ openjdk21 ]}
|
|
'';
|
|
|
|
meta = {
|
|
description = "Software reverse engineering (SRE) suite of tools developed by NSA's Research Directorate in support of the Cybersecurity mission";
|
|
mainProgram = "ghidra";
|
|
homepage = "https://github.com/NationalSecurityAgency/ghidra";
|
|
platforms = [
|
|
"x86_64-linux"
|
|
"aarch64-linux"
|
|
"aarch64-darwin"
|
|
];
|
|
sourceProvenance = with lib.sourceTypes; [ binaryBytecode ];
|
|
license = lib.licenses.asl20;
|
|
maintainers = with lib.maintainers; [
|
|
ck3d
|
|
govanify
|
|
tbaldwin
|
|
mic92
|
|
];
|
|
};
|
|
|
|
}
|