Ghidra: Difference between revisions
Add details about using an overlay to update Ghidra and give an example of adding extensions |
m Add category development |
||
| (2 intermediate revisions by one other user not shown) | |||
| Line 5: | Line 5: | ||
Ghidra can be installed from nixpkgs from source via the <code>ghidra</code> package or as a pre-packaged build using <code>ghidra-bin</code>. | Ghidra can be installed from nixpkgs from source via the <code>ghidra</code> package or as a pre-packaged build using <code>ghidra-bin</code>. | ||
There are a number of [https://github.com/NixOS/nixpkgs/tree/nixos-unstable/pkgs/tools/security/ghidra/extensions extensions] already supported in nixpkgs. If you want to build Ghidra with some extensions included, you can use the | There are a number of [https://github.com/NixOS/nixpkgs/tree/nixos-unstable/pkgs/tools/security/ghidra/extensions extensions] already supported in nixpkgs. Note that extensions ''cannot'' be used with the <code>ghidra-bin</code> package. If you want to build Ghidra with some extensions included, you can use the following: | ||
following: | |||
<syntaxhighlight lang="nix"> | <syntaxhighlight lang="nix"> | ||
| Line 14: | Line 13: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
=== Ghidra overlays === | |||
=== Ghidra | |||
Updating the <code>ghidra</code> package using an overlay is not as easy as most common packages in nixpkgs, due to it's | Updating the <code>ghidra</code> package using an overlay is not as easy as most common packages in nixpkgs, due to it's | ||
| Line 59: | Line 56: | ||
''; | ''; | ||
}; | }; | ||
</syntaxhighlight> | |||
=== Declarative preferences === | |||
Although not built-in directly to the <code>ghidra</code> package, it's possible to create a declarative Ghidra <code>preferences</code> file. This does have the caveat that by making the file read-only, Ghidra will not be able to update it with new settings at runtime. | |||
{{Note|If you prefer not to make the file read-only, you could optionally copy the read-only version from the [[Nix_package_manager#Nix_store|Nix store]] into the Ghidra settings | |||
folder, allowing you to then diff out settings you wish to make declarative. This is not currently shown.}} | |||
The following is an example, using [[Home_Manager|Home Manager]], of how you might setup your Preferences file: | |||
<syntaxhighlight lang="nix"> | |||
{ | |||
lib, | |||
pkgs, | |||
config, | |||
... | |||
}: | |||
let | |||
ghidra_pkg = pkgs.ghidra.withExtensions ( | |||
exts: | |||
builtins.attrValues { | |||
# inherit (exts) <plugin-name>; | |||
} | |||
); | |||
ghidra_dir = ".config/ghidra/${pkgs.ghidra.distroPrefix}"; | |||
in | |||
{ | |||
home = { | |||
packages = [ ghidra_pkg ]; | |||
file = { | |||
"${ghidra_dir}/preferences".text = '' | |||
GhidraShowWhatsNew=false | |||
SHOW.HELP.NAVIGATION.AID=true | |||
SHOW_TIPS=false | |||
TIP_INDEX=0 | |||
G_FILE_CHOOSER.ShowDotFiles=true | |||
USER_AGREEMENT=ACCEPT | |||
LastExtensionImportDirectory=${config.home.homeDirectory}/.config/ghidra/scripts/ | |||
LastNewProjectDirectory=${config.home.homeDirectory}/.config/ghidra/repos/ | |||
ViewedProjects= | |||
RecentProjects= | |||
''; | |||
}; | |||
}; | |||
} | |||
// (lib.optionalAttrs pkgs.stdenv.isLinux { | |||
systemd.user.tmpfiles.rules = [ | |||
# https://www.man7.org/linux/man-pages/man5/tmpfiles.d.5.html | |||
"d %h/${ghidra_dir} 0700 - - -" | |||
"L+ %h/.config/ghidra/latest - - - - %h/${ghidra_dir}" | |||
"d %h/.config/ghidra/scripts 0700 - - -" | |||
"d %h/.config/ghidra/repos 0700 - - -" | |||
]; | |||
}) | |||
</syntaxhighlight> | </syntaxhighlight> | ||
| Line 87: | Line 139: | ||
} | } | ||
</syntaxhighlight> | </syntaxhighlight> | ||
[[Category:Development]] | |||