From 1058f242ea421a88eca823eebc1a69a09e2eb6e6 Mon Sep 17 00:00:00 2001 From: Simon Garrelou Date: Thu, 30 Nov 2023 15:05:33 +0100 Subject: add idafree --- pkgs/idafree/default.nix | 4 ++ pkgs/idafree/package.nix | 125 +++++++++++++++++++++++++++++++++++++++++++++++ pkgs/idafree/srcs.json | 14 ++++++ pkgs/idafree/update.sh | 26 ++++++++++ 4 files changed, 169 insertions(+) create mode 100644 pkgs/idafree/default.nix create mode 100644 pkgs/idafree/package.nix create mode 100644 pkgs/idafree/srcs.json create mode 100755 pkgs/idafree/update.sh (limited to 'pkgs/idafree') diff --git a/pkgs/idafree/default.nix b/pkgs/idafree/default.nix new file mode 100644 index 0000000..28b6df8 --- /dev/null +++ b/pkgs/idafree/default.nix @@ -0,0 +1,4 @@ +let + pkgs = import {}; +in +pkgs.callPackage ./package.nix {} diff --git a/pkgs/idafree/package.nix b/pkgs/idafree/package.nix new file mode 100644 index 0000000..d29a54f --- /dev/null +++ b/pkgs/idafree/package.nix @@ -0,0 +1,125 @@ +# Copy from https://github.com/NixOS/nixpkgs/pull/217753 +{ lib +, stdenv +, fetchurl +, libGL +, zlib +, libkrb5 +, libsecret +, libunwind +, libxkbcommon +, glib +, makeWrapper +, openssl +, xorg +, dbus +, fontconfig +, freetype +, makeDesktopItem +}: + + +let + srcs = builtins.fromJSON (builtins.readFile ./srcs.json); +in + +stdenv.mkDerivation rec { + pname = "ida-free"; + version = "8.2.230124"; + + src = fetchurl { + inherit (srcs.${stdenv.system}) url sha256; + }; + + icon = fetchurl { + urls = [ + "https://www.hex-rays.com/products/ida/news/8_1/images/icon_free.png" + "https://web.archive.org/web/20221105181231if_/https://hex-rays.com/products/ida/news/8_1/images/icon_free.png" + ]; + sha256 = "sha256-widkv2VGh+eOauUK/6Sz/e2auCNFAsc8n9z0fdrSnW0="; + }; + + desktopItem = makeDesktopItem { + name = pname; + exec = "ida64"; + icon = icon; + comment = "Freeware version of the world's smartest and most feature-full disassembler"; + desktopName = "IDA Free"; + genericName = "Interactive Disassembler"; + categories = [ "Development" ]; + }; + + ldLibraryPath = lib.makeLibraryPath [ + stdenv.cc.cc + zlib + glib + xorg.libXi + xorg.libxcb + xorg.libXrender + xorg.libXau + xorg.libX11 + xorg.libSM + xorg.libICE + xorg.libXext + xorg.xcbutilwm + xorg.xcbutilimage + xorg.xcbutilkeysyms + xorg.xcbutilrenderutil + libkrb5 + libsecret + libunwind + libxkbcommon + openssl + dbus + fontconfig + freetype + libGL + ]; + + nativeBuildInputs = [ makeWrapper ]; + + dontUnpack = true; + dontStrip = true; + dontPatchELF = true; + + installPhase = '' + runHook preInstall + + IDADIR=$out/opt/${pname} + + install -d $IDADIR $out/bin $out/share/applications + + # Invoke the installer with the dynamic loader directly, avoiding the need + # to copy it to fix permissions and patch the executable. + $(cat $NIX_CC/nix-support/dynamic-linker) ${src} \ + --mode unattended --prefix $IDADIR --installpassword "" + + rm $IDADIR/[Uu]ninstall* + + for bb in ida64 assistant; do + patchelf --set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) $IDADIR/$bb + wrapProgram \ + $IDADIR/$bb \ + --set LD_LIBRARY_PATH "$IDADIR:${ldLibraryPath}" \ + --set QT_PLUGIN_PATH "$IDADIR/plugins/platforms" + done + + ln -s $IDADIR/ida64 $out/bin/ida64 + + cp $desktopItem/share/applications/* $out/share/applications + + runHook postInstall + ''; + + passthru.updateScript = ./update.sh; + + meta = with lib; { + description = "Freeware version of the world's smartest and most feature-full disassembler"; + homepage = "https://hex-rays.com/ida-free/"; + sourceProvenance = with sourceTypes; [ binaryNativeCode ]; + license = licenses.unfree; + maintainers = with maintainers; [ lourkeur ]; + platforms = [ "x86_64-linux" "x86_64-darwin" "aarch64-darwin" ]; + mainProgram = "ida64"; + }; +} diff --git a/pkgs/idafree/srcs.json b/pkgs/idafree/srcs.json new file mode 100644 index 0000000..73169bd --- /dev/null +++ b/pkgs/idafree/srcs.json @@ -0,0 +1,14 @@ +{ + "x86_64-linux": { + "url": "https://out7.hex-rays.com/files/idafree83_linux.run", + "sha256": "10haw0nrsinr0aj77xcjzimmr7mwxdffwr5y48bg1m7j68adk4xb" + }, + "x86_64-darwin": { + "url": "https://out7.hex-rays.com/files/idafree83_mac.app.zip", + "sha256": "04gfq21ranm6zydbjqag3ll9ij8ml8m5g13dv0jlp32iyvdpkip1" + }, + "aarch64-darwin": { + "url": "https://out7.hex-rays.com/files/arm_idafree83_mac.app.zip", + "sha256": "14l9giafygxnkwrma6bq8rxsjiy1cgrp9l2pwsbmcgqgchk0gzaj" + } +} diff --git a/pkgs/idafree/update.sh b/pkgs/idafree/update.sh new file mode 100755 index 0000000..cf4068e --- /dev/null +++ b/pkgs/idafree/update.sh @@ -0,0 +1,26 @@ +#! /usr/bin/env nix-shell +#! nix-shell -i bash -p bash curl jq + +set -e + +urls=( + https://out7.hex-rays.com/files/idafree83_linux.run + https://out7.hex-rays.com/files/idafree83_mac.app.zip + https://out7.hex-rays.com/files/arm_idafree83_mac.app.zip +) + +archs=( + x86_64-linux + x86_64-darwin + aarch64-darwin +) + +hashes=() +for u in "${urls[@]}"; do + hash=$(nix-prefetch-url $u) + hashes=("${hashes[@]}" "$hash") +done + +for ((i = 0; i < ${#urls[@]}; i++)); do + echo '{"key":"'${archs[i]}'", "value":{"url":"'${urls[i]}'", "sha256":"'${hashes[i]}'"}}' +done | jq -s from_entries >pkgs/development/tools/analysis/ida-free/srcs.json -- cgit v1.2.3