-
-
Notifications
You must be signed in to change notification settings - Fork 14.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ghidra: chore run nixfmt-rfc-style on ghidra dir
- Loading branch information
Showing
8 changed files
with
177 additions
and
133 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,77 +1,98 @@ | ||
{ lib | ||
, stdenv | ||
, unzip | ||
, jdk | ||
, gradle | ||
, ghidra | ||
{ | ||
lib, | ||
stdenv, | ||
unzip, | ||
jdk, | ||
gradle, | ||
ghidra, | ||
}: | ||
|
||
let | ||
metaCommon = oldMeta: | ||
oldMeta // (with lib; { | ||
maintainers = (oldMeta.maintainers or []) ++ (with maintainers; [ vringar ]); | ||
metaCommon = | ||
oldMeta: | ||
oldMeta | ||
// (with lib; { | ||
maintainers = (oldMeta.maintainers or [ ]) ++ (with maintainers; [ vringar ]); | ||
platforms = oldMeta.platforms or ghidra.meta.platforms; | ||
}); | ||
|
||
buildGhidraExtension = { | ||
pname, nativeBuildInputs ? [], meta ? { }, ... | ||
}@args: | ||
stdenv.mkDerivation (args // { | ||
nativeBuildInputs = nativeBuildInputs ++ [ | ||
unzip | ||
jdk | ||
gradle | ||
]; | ||
buildGhidraExtension = | ||
{ | ||
pname, | ||
nativeBuildInputs ? [ ], | ||
meta ? { }, | ||
... | ||
}@args: | ||
stdenv.mkDerivation ( | ||
args | ||
// { | ||
nativeBuildInputs = nativeBuildInputs ++ [ | ||
unzip | ||
jdk | ||
gradle | ||
]; | ||
|
||
preBuild = '' | ||
# Set project name, otherwise defaults to directory name | ||
echo -e '\nrootProject.name = "${pname}"' >> settings.gradle | ||
# A config directory needs to exist when ghidra's GHelpBuilder is run | ||
export XDG_CONFIG_HOME="''${XDG_CONFIG_HOME:-$(mktemp -d)}" | ||
${args.preBuild or ""} | ||
''; | ||
preBuild = '' | ||
# Set project name, otherwise defaults to directory name | ||
echo -e '\nrootProject.name = "${pname}"' >> settings.gradle | ||
# A config directory needs to exist when ghidra's GHelpBuilder is run | ||
export XDG_CONFIG_HOME="''${XDG_CONFIG_HOME:-$(mktemp -d)}" | ||
${args.preBuild or ""} | ||
''; | ||
|
||
# Needed to run gradle on darwin | ||
__darwinAllowLocalNetworking = true; | ||
# Needed to run gradle on darwin | ||
__darwinAllowLocalNetworking = true; | ||
|
||
gradleBuildTask = args.gradleBuildTask or "buildExtension"; | ||
gradleFlags = args.gradleFlags or [ ] ++ [ "-PGHIDRA_INSTALL_DIR=${ghidra}/lib/ghidra" ]; | ||
gradleBuildTask = args.gradleBuildTask or "buildExtension"; | ||
gradleFlags = args.gradleFlags or [ ] ++ [ "-PGHIDRA_INSTALL_DIR=${ghidra}/lib/ghidra" ]; | ||
|
||
installPhase = args.installPhase or '' | ||
runHook preInstall | ||
installPhase = | ||
args.installPhase or '' | ||
runHook preInstall | ||
mkdir -p $out/lib/ghidra/Ghidra/Extensions | ||
unzip -d $out/lib/ghidra/Ghidra/Extensions dist/*.zip | ||
mkdir -p $out/lib/ghidra/Ghidra/Extensions | ||
unzip -d $out/lib/ghidra/Ghidra/Extensions dist/*.zip | ||
runHook postInstall | ||
''; | ||
runHook postInstall | ||
''; | ||
|
||
meta = metaCommon meta; | ||
}); | ||
meta = metaCommon meta; | ||
} | ||
); | ||
|
||
buildGhidraScripts = { pname, meta ? { }, ... }@args: | ||
stdenv.mkDerivation (args // { | ||
installPhase = '' | ||
runHook preInstall | ||
buildGhidraScripts = | ||
{ | ||
pname, | ||
meta ? { }, | ||
... | ||
}@args: | ||
stdenv.mkDerivation ( | ||
args | ||
// { | ||
installPhase = '' | ||
runHook preInstall | ||
GHIDRA_HOME=$out/lib/ghidra/Ghidra/Extensions/${pname} | ||
mkdir -p $GHIDRA_HOME | ||
cp -r . $GHIDRA_HOME/ghidra_scripts | ||
GHIDRA_HOME=$out/lib/ghidra/Ghidra/Extensions/${pname} | ||
mkdir -p $GHIDRA_HOME | ||
cp -r . $GHIDRA_HOME/ghidra_scripts | ||
touch $GHIDRA_HOME/Module.manifest | ||
cat <<'EOF' > extension.properties | ||
name=${pname} | ||
description=${meta.description or ""} | ||
author= | ||
createdOn= | ||
version=${lib.getVersion ghidra} | ||
touch $GHIDRA_HOME/Module.manifest | ||
cat <<'EOF' > extension.properties | ||
name=${pname} | ||
description=${meta.description or ""} | ||
author= | ||
createdOn= | ||
version=${lib.getVersion ghidra} | ||
EOF | ||
EOF | ||
runHook postInstall | ||
''; | ||
runHook postInstall | ||
''; | ||
|
||
meta = metaCommon meta; | ||
}); | ||
meta = metaCommon meta; | ||
} | ||
); | ||
in | ||
{ inherit buildGhidraExtension buildGhidraScripts; } | ||
{ | ||
inherit buildGhidraExtension buildGhidraScripts; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 7 additions & 6 deletions
13
pkgs/tools/security/ghidra/extensions/ghidraninja-ghidra-scripts/default.nix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.