summaryrefslogtreecommitdiffstats
path: root/nixos/modules/programs/ghidra.nix
blob: a832a2161e769bcc518d5af4f315761131c9cf8f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
{
  config,
  lib,
  pkgs,
  ...
}:

let
  cfg = config.programs.ghidra;
in
{
  options.programs.ghidra = {
    enable = lib.mkEnableOption "Ghidra, a software reverse engineering (SRE) suite of tools";

    gdb = lib.mkOption {
      default = true;
      type = lib.types.bool;
      description = ''
        Whether to add to gdbinit the python modules required to make Ghidra's debugger work.
      '';
    };

    package = lib.mkPackageOption pkgs "ghidra" { example = "ghidra-bin"; };
  };

  config = lib.mkIf cfg.enable {
    environment = {
      systemPackages = [ cfg.package ];

      etc = lib.mkIf cfg.gdb {
        "gdb/gdbinit.d/ghidra-modules.gdb".text = with pkgs.python3.pkgs; ''
          python
          import sys
          [sys.path.append(p) for p in "${
            (makePythonPath [
              psutil
              protobuf
            ])
          }".split(":")]
          end
        '';
      };
    };
  };

  meta.maintainers = with lib.maintainers; [ govanify ];
}