182 lines
4.3 KiB
Nix
182 lines
4.3 KiB
Nix
{
|
|
lib,
|
|
stdenv,
|
|
fetchurl,
|
|
autoPatchelfHook,
|
|
copyDesktopItems,
|
|
python311,
|
|
qt6,
|
|
cairo,
|
|
dbus,
|
|
fontconfig,
|
|
freetype,
|
|
glib,
|
|
gtk3,
|
|
libdrm,
|
|
libGL,
|
|
libkrb5,
|
|
libsecret,
|
|
libunwind,
|
|
libxkbcommon,
|
|
openssl,
|
|
gcc,
|
|
clang,
|
|
xorg,
|
|
zlib,
|
|
curl,
|
|
gnutar,
|
|
makeDesktopItem,
|
|
makeWrapper,
|
|
runCommand,
|
|
|
|
_errorMessage ? builtins.throw ''
|
|
No source and/or version for package `idapro` was provided.
|
|
Please provide a source file and version number using, for example:
|
|
|
|
pkgs.idapro.override {
|
|
idaSource = pkgs.requireFile rec {
|
|
name = "my-idapro-source.tar.xz";
|
|
hash = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=";
|
|
message = '''
|
|
Please run `nix store add-file ''${name}`
|
|
The value of `nix hash file ''${name}` should be ''${hash}
|
|
''';
|
|
};
|
|
|
|
idaVersion = "9.x.y";
|
|
}
|
|
|
|
The source file must be a tarball with a single directory inside containing the IDA Pro
|
|
installation. This will be extracted and patched to be able to run on NixOS.
|
|
|
|
Version 9.2 is currently supported by this derivation.
|
|
'',
|
|
# the IDA Pro tarball to extract, patch and repackage
|
|
# the reason i'm not providing an exact requireFile spec is that people's IDA Pro tarballs
|
|
# may vary, and this derivation nominally allows packaging many different versions of IDA Pro
|
|
# (though it's actually just 9.2 for now)
|
|
idaSource ? _errorMessage,
|
|
# the version of IDA pro being built
|
|
idaVersion ? _errorMessage,
|
|
# the python version to use for idapython
|
|
pythonPackage ? python311,
|
|
# additional python packages to make available to idapython
|
|
pythonDeps ? [],
|
|
}: let
|
|
defaultPythonDeps = ps: with ps; [
|
|
rpyc
|
|
];
|
|
pythonEnv =
|
|
pythonPackage.withPackages
|
|
(ps: (defaultPythonDeps ps) ++ pythonDeps);
|
|
in stdenv.mkDerivation (self: {
|
|
pname = "idapro";
|
|
version = idaVersion;
|
|
src = idaSource;
|
|
|
|
nativeBuildInputs = [
|
|
autoPatchelfHook
|
|
copyDesktopItems
|
|
makeWrapper
|
|
];
|
|
|
|
# Add everything to the RPATH, in case IDA decides to dlopen things.
|
|
runtimeDependencies = [
|
|
cairo
|
|
dbus
|
|
fontconfig
|
|
freetype
|
|
glib
|
|
gtk3
|
|
libdrm
|
|
libGL
|
|
libkrb5
|
|
libsecret
|
|
libunwind
|
|
libxkbcommon
|
|
openssl.out
|
|
(if stdenv.cc.isGNU then gcc else clang).cc
|
|
xorg.libICE
|
|
xorg.libSM
|
|
xorg.libX11
|
|
xorg.libXau
|
|
xorg.libxcb
|
|
xorg.libXext
|
|
xorg.libXi
|
|
xorg.libXrender
|
|
xorg.xcbutilimage
|
|
xorg.xcbutilkeysyms
|
|
xorg.xcbutilrenderutil
|
|
xorg.xcbutilwm
|
|
zlib
|
|
curl.out
|
|
qt6.qtwayland
|
|
pythonEnv
|
|
];
|
|
|
|
buildInputs = self.runtimeDependencies;
|
|
|
|
qtWrapperArgs = [];
|
|
|
|
installPhase = ''
|
|
runHook preInstall
|
|
|
|
mkdir -p $out/opt $out/lib $out/bin
|
|
cp -a * $out/opt
|
|
|
|
# Link the exported libraries to the output.
|
|
for lib in $out/opt/libida*; do
|
|
ln -s $lib $out/lib/$(basename $lib)
|
|
done
|
|
|
|
ln -s $out/opt/ida $out/bin/ida
|
|
|
|
mkdir -p $out/share/icons/hicolor/128x128/apps
|
|
cp $out/opt/appico.png $out/share/icons/hicolor/128x128/apps/idapro.png
|
|
|
|
runHook postInstall
|
|
'';
|
|
|
|
preFixup = ''
|
|
# Some libraries come with the installer.
|
|
addAutoPatchelfSearchPath $out/opt
|
|
|
|
# Manually patch libraries that dlopen stuff.
|
|
patchelf --add-needed libpython${pythonEnv.pythonVersion}.so $out/lib/libida.so
|
|
patchelf --add-needed libpython${pythonEnv.pythonVersion}.so $out/opt/plugins/idapython3.so
|
|
patchelf --add-needed libcrypto.so $out/lib/libida.so
|
|
patchelf --add-needed libcrypto.so $out/opt/plugins/idapython3.so
|
|
|
|
wrapProgram "$out/opt/ida" \
|
|
--prefix PYTHONPATH : $out/opt/idalib/python \
|
|
--prefix PATH : ${pythonEnv}/bin
|
|
'';
|
|
|
|
dontWrapQtApps = true;
|
|
|
|
desktopItem = makeDesktopItem {
|
|
name = "ida-pro";
|
|
exec = "ida";
|
|
icon = "idapro";
|
|
comment = self.meta.description;
|
|
desktopName = "IDA Pro";
|
|
genericName = "Interactive Disassembler";
|
|
categories = [ "Development" ];
|
|
startupWMClass = "IDA";
|
|
};
|
|
desktopItems = [ self.desktopItem ];
|
|
|
|
passthru = {
|
|
inherit pythonEnv;
|
|
};
|
|
|
|
meta = with lib; {
|
|
description = "A powerful disassembler, decompiler and a versatile debugger.";
|
|
homepage = "https://hex-rays.com/ida-pro";
|
|
mainProgram = "ida";
|
|
platforms = [ "x86_64-linux" ];
|
|
sourceProvenance = with sourceTypes; [ binaryNativeCode ];
|
|
license = lib.licenses.unfree;
|
|
};
|
|
})
|