nixos-config/pkgs/idapro9.nix

158 lines
3.4 KiB
Nix

{
lib,
stdenv,
requireFile,
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,
}:
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.2.250908";
src = requireFile {
name = "idapro-linux-9.2.250908.tar.xz";
hash = "sha256-daQtHbJxCuKzfGiBzkmy7FOTCMEJX3WL7IwuuvwIi+Y=";
message = ''
Please run nix store add-file idapro-linux-9.2.250908.tar.xz
Its sha256sum should be 75a42d1db2710ae2b37c6881ce49b2ec539308c1095f758bec8c2ebafc088be6
'';
};
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
qt6.qtwayland
];
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/ida64
ln -s $out/opt/ida $out/bin/ida
ln -s ${pythonForIDA}/bin/binsync $out/bin/binsync
runHook postInstall
'';
preFixup = ''
# 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.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 : ${pythonForIDA}/bin
'';
dontWrapQtApps = true;
desktopItem = makeDesktopItem {
name = "ida-pro";
exec = "ida";
icon = runCommand "appico.png" {nativeBuildInputs = [gnutar]; strictDeps = true;} ''
tar --to-command cat -xf ${self.src} 'idapro-linux-9.2.250908/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 ];
};
})