nixos-config/pkgs/idapro9.nix

159 lines
3.7 KiB
Nix

{
lib,
stdenv,
requireFile,
fetchurl,
autoPatchelfHook,
copyDesktopItems,
python311,
libsForQt5,
cairo,
dbus,
fontconfig,
freetype,
glib,
gtk3,
libdrm,
libGL,
libkrb5,
libsecret,
libunwind,
libxkbcommon,
openssl,
gcc,
clang,
xorg,
zlib,
curl,
gnutar,
makeDesktopItem,
makeWrapper,
runCommand,
}:
let
pythonForIDA = python311.withPackages (ps: with ps; [
rpyc
(ps.callPackage ./binsync.nix {})
]);
in
# https://github.com/msanft/ida-pro-overlay/blob/main/packages/ida-pro.nix
stdenv.mkDerivation (self: {
pname = "idapro";
version = "9.0.240807";
src = requireFile {
name = "IDA_Pro_Linux_9.tar.gz";
hash = "sha256-PKbEHc8dPHOMwv76xjoMUoeSn1jF7VXF9QUmQ4YSmP0=";
message = ''
Please run nix store add-file IDA_Pro_Linux_9.tar.gz
Its sha256sum should be 3ca6c41dcf1d3c738cc2fefac63a0c5287929f58c5ed55c5f5052643861298fd
'';
};
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
pythonForIDA
];
buildInputs = self.runtimeDependencies;
qtWrapperArgs = [
];
installPhase = ''
runHook preInstall
mkdir -p $out/opt $out/lib $out/bin
cp ${libsForQt5.qtbase.out}/lib/libQt5EglFSDeviceIntegration.so.5 .
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/ida64 $out/bin/ida64
ln -s $out/opt/ida64 $out/bin/ida
ln -s ${pythonForIDA}/bin/binsync $out/bin/binsync
runHook postInstall
'';
preFixup = ''
patchelf --shrink-rpath --allowed-rpath-prefixes $(patchelf --print-rpath $out/opt/libQt5EglFSDeviceIntegration.so.5 | sed 's/:/\n/g' | grep -v qtbase | paste -s -d: -) $out/opt/libQt5EglFSDeviceIntegration.so.5
# Some libraries come with the installer.
addAutoPatchelfSearchPath $out/opt
# Manually patch libraries that dlopen stuff.
patchelf --add-needed libpython${pythonForIDA.pythonVersion}.so $out/lib/libida.so
patchelf --add-needed libpython${pythonForIDA.pythonVersion}.so $out/opt/plugins/idapython3_64.so
patchelf --add-needed libcrypto.so $out/lib/libida.so
patchelf --add-needed libcrypto.so $out/opt/plugins/idapython3_64.so
wrapProgram "$out/opt/ida64" \
--prefix PYTHONPATH : $out/opt/idalib/python \
--prefix PATH : ${pythonForIDA}/bin
'';
#--prefix QT_PLUGIN_PATH : $out/opt/plugins/platforms \
desktopItem = makeDesktopItem {
name = "ida-pro";
exec = "ida";
icon = runCommand "appico.png" {nativeBuildInputs = [gnutar]; strictDeps = true;} ''
tar --to-command cat -xf ${self.src} './idapro-9.0/appico.png' > "$out"
'';
comment = self.meta.description;
desktopName = "IDA Pro";
genericName = "Interactive Disassembler";
categories = [ "Development" ];
startupWMClass = "IDA";
};
desktopItems = [ self.desktopItem ];
passthru = {
inherit pythonForIDA;
};
meta = with lib; {
description = "The world's smartest and most feature-full disassembler";
homepage = "https://hex-rays.com/ida-pro/";
mainProgram = "ida";
platforms = [ "x86_64-linux" ];
sourceProvenance = with sourceTypes; [ binaryNativeCode ];
};
})