aboutsummaryrefslogtreecommitdiff
path: root/pkgs/idafree/package.nix
blob: d29a54f06d30d75362c75665f193963977c08624 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
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";
  };
}