nixos-config/pkgs/idapro9.nix

149 lines
3.4 KiB
Nix

{
lib,
stdenv,
requireFile,
fetchurl,
autoPatchelfHook,
copyDesktopItems,
python3,
libsForQt5,
cairo,
dbus,
fontconfig,
freetype,
glib,
gtk3,
libdrm,
libGL,
libkrb5,
libsecret,
libunwind,
libxkbcommon,
openssl,
gcc,
clang,
xorg,
zlib,
curl,
makeDesktopItem,
makeWrapper,
}:
let
pythonForIDA = python3.withPackages (ps: with ps; [ rpyc ]);
in
# https://github.com/msanft/ida-pro-overlay/blob/main/packages/ida-pro.nix
stdenv.mkDerivation (self: {
pname = "idapro";
version = "9.0.241217";
src = requireFile {
name = "idapro-9.0.241217.tar.xz";
hash = "sha256-V6RYQlwY8qYlASkyUZx2NgIkuQhf2fTd1tA7MFpOqLc=";
message = ''
Please run nix store add-file idapro-9.0.241217.tar.xz
Its sha256sum should be 57a458425c18f2a625012932519c76360224b9085fd9f4ddd6d03b305a4ea8b7
'';
};
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/ida $out/bin/ida
ln -s ida $out/bin/ida64
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 libpython3.12.so $out/lib/libida.so
patchelf --add-needed libcrypto.so $out/lib/libida.so
wrapProgram "$out/opt/ida" \
--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 = fetchurl {
url = "https://www.xzji.com/upload/y20/07x15/1518115f0eadb3d25ab.png";
name = "appico.png";
hash = "sha256-mso/8F4AT5Ry1RHG3plo03rssRRUw9xBwu3fjh8PqYc";
};
comment = self.meta.description;
desktopName = "IDA Pro";
genericName = "Interactive Disassembler";
categories = [ "Development" ];
startupWMClass = "IDA";
};
desktopItems = [ self.desktopItem ];
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 ];
};
})