From 0aa088137741c475c95ced7e201d14577e2044cb Mon Sep 17 00:00:00 2001 From: xenia Date: Fri, 12 Sep 2025 02:14:30 -0400 Subject: [PATCH] add programs.idapro --- README.md | 20 +++++++++ module.nix | 1 + modules/idapro/default.nix | 44 ++++++++++++++++++++ pkgs/reverse-engineering/idapro9/default.nix | 9 ++-- 4 files changed, 71 insertions(+), 3 deletions(-) create mode 100644 modules/idapro/default.nix diff --git a/README.md b/README.md index 3c1f8cc..0bb6b55 100644 --- a/README.md +++ b/README.md @@ -336,6 +336,26 @@ example: enable binsync integration +### [`programs.idapro`](./modules/idapro/default.nix) + +Enables IDA Pro in the system environment, with optional plugin config. + +This also directs IDA Pro to use `~/.config/idapro` as its main user config directory, instead of +`~/.idapro`. Unfortunately, as of IDA Pro 9.2, `~/.idapro` still gets created, though it will be +empty. + +#### `programs.idapro.enable` + +Whether to enable IDA Pro + +#### `programs.idapro.package` + +The IDA Pro package to use + +#### `programs.idapro.binsync.enable` + +Enables binsync integration with IDA Pro + ### [`environment.machineInfo`](./modules/machine-info/default.nix) provides options to customize the `/etc/machine-info` file on a NixOS system. See the module itself diff --git a/module.nix b/module.nix index e39085a..82f488d 100644 --- a/module.nix +++ b/module.nix @@ -2,6 +2,7 @@ imports = [ ./modules/ghidra-client ./modules/ghidra-server + ./modules/idapro ./modules/machine-info ./modules/regdom ./modules/satisfactory-dedicated-server diff --git a/modules/idapro/default.nix b/modules/idapro/default.nix new file mode 100644 index 0000000..9b0ea53 --- /dev/null +++ b/modules/idapro/default.nix @@ -0,0 +1,44 @@ +{ + config, + lib, + pkgs, + ... +}: + +let + cfg = config.programs.idapro; + binsyncPkg = pkgs.python311.pkgs.binsync; + binsyncPath = "${pkgs.python311.pkgs.binsync}/${pkgs.python311.sitePackages}"; + idaproConfigured = cfg.package.override { + pythonDeps = lib.optionals cfg.binsync.enable [binsyncPkg]; + plugins = lib.optionals cfg.binsync.enable [ + (pkgs.runCommand "binsync-ida" {} '' + mkdir -p $out/plugins + cp ${binsyncPath}/binsync/binsync_plugin.py $out/plugins + '') + ]; + }; +in +{ + options.programs.idapro = { + enable = lib.mkEnableOption "IDA Pro"; + + package = lib.mkPackageOption pkgs "idapro" { + example = lib.literalExpression "idapro.override { ... }"; + }; + + binsync = { + enable = lib.mkEnableOption "IDA binsync integration"; + }; + }; + + config = lib.mkIf cfg.enable { + environment = { + systemPackages = [ + idaproConfigured + ]; + + sessionVariables.IDAUSR = "$HOME/.config/idapro"; + }; + }; +} diff --git a/pkgs/reverse-engineering/idapro9/default.nix b/pkgs/reverse-engineering/idapro9/default.nix index c931630..cdb7999 100644 --- a/pkgs/reverse-engineering/idapro9/default.nix +++ b/pkgs/reverse-engineering/idapro9/default.nix @@ -26,7 +26,7 @@ curl, gnutar, makeDesktopItem, - makeWrapper, + makeBinaryWrapper, runCommand, _errorMessage ? builtins.throw '' @@ -62,6 +62,8 @@ pythonPackage ? python311, # additional python packages to make available to idapython pythonDeps ? [], + # dirs to prepend to IDAUSR + plugins ? [], }: let defaultPythonDeps = ps: with ps; [ rpyc @@ -77,7 +79,7 @@ in stdenv.mkDerivation (self: { nativeBuildInputs = [ autoPatchelfHook copyDesktopItems - makeWrapper + makeBinaryWrapper ]; # Add everything to the RPATH, in case IDA decides to dlopen things. @@ -149,7 +151,8 @@ in stdenv.mkDerivation (self: { wrapProgram "$out/opt/ida" \ --prefix PYTHONPATH : $out/opt/idalib/python \ - --prefix PATH : ${pythonEnv}/bin + --prefix PATH : ${pythonEnv}/bin \ + --suffix IDAUSR : "${lib.makeSearchPath "" plugins}" ''; dontWrapQtApps = true;