forked from jchv/nix-binary-ninja
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpackage.nix
More file actions
130 lines (123 loc) · 3.17 KB
/
Copy pathpackage.nix
File metadata and controls
130 lines (123 loc) · 3.17 KB
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
126
127
128
129
130
{
lib,
stdenv,
callPackage,
fetchurl,
auto-patchelf,
autoPatchelfHook,
makeWrapper,
makeDesktopItem,
copyDesktopItems,
unzip,
libGL,
glib,
fontconfig,
xorg,
dbus,
libxkbcommon,
wayland,
kdePackages,
python3,
libxml2,
binaryNinjaEdition ? "personal",
forceWayland ? false,
overrideSource ? null,
}:
let
sources = callPackage ./sources.nix { };
platformSources = sources.editions.${binaryNinjaEdition};
source =
if overrideSource != null then
overrideSource
else if builtins.hasAttr stdenv.hostPlatform.system platformSources then
platformSources.${stdenv.hostPlatform.system}
else
throw "No source for system ${stdenv.hostPlatform.system}";
desktopIcon = fetchurl {
url = "https://docs.binary.ninja/img/logo.png";
hash = "sha256-TzGAAefTknnOBj70IHe64D6VwRKqIDpL4+o9kTw0Mn4=";
};
in
stdenv.mkDerivation {
pname = "binary-ninja";
inherit (sources) version;
src = source;
nativeBuildInputs = [
makeWrapper
auto-patchelf
autoPatchelfHook
python3.pkgs.wrapPython
kdePackages.wrapQtAppsHook
copyDesktopItems
];
buildInputs = [
unzip
libGL
glib
fontconfig
xorg.libXi
xorg.libXrender
xorg.xcbutilimage
xorg.xcbutilrenderutil
kdePackages.qtbase
kdePackages.qtdeclarative
kdePackages.qtwayland
libxkbcommon
dbus
wayland
libxml2.out
];
pythonDeps = [ python3.pkgs.pip ];
appendRunpaths = [ "${lib.getLib python3}/lib" ];
qtWrapperArgs = lib.optionals forceWayland [
"--set"
"QT_QPA_PLATFORM"
"wayland"
];
buildPhase = ":";
desktopItems = [
(makeDesktopItem {
name = "Binary Ninja";
exec = "binaryninja";
icon = "binaryninja";
desktopName = "Binary Ninja";
comment = "Binary Ninja is an interactive decompiler, disassembler, debugger, and binary analysis platform built by reverse engineers, for reverse engineers";
categories = [ "Development" ];
})
];
installPhase = ''
runHook preInstall
mkdir -p $out/bin
mkdir -p $out/opt/binaryninja
mkdir -p $out/share/pixmaps
cp -r * $out/opt/binaryninja
find $out/opt/binaryninja \
-type f \
-name '*.so.*' \
-not -name 'libbinaryninjacore.so.*' \
-not -name 'libbinaryninjaui.so.*' \
-not -name 'liblldb.so.*' \
-not -name 'libshiboken6.abi*.so.*' \
-not -name 'libpyside6.abi*.so.*' \
-delete
cp ${desktopIcon} $out/share/pixmaps/binaryninja.png
chmod +x $out/opt/binaryninja/binaryninja
buildPythonPath "$pythonDeps"
makeWrapper $out/opt/binaryninja/binaryninja $out/bin/binaryninja \
--prefix PYTHONPATH : "$program_PYTHONPATH" \
"''${qtWrapperArgs[@]}"
runHook postInstall
'';
# libxml2 soname changes now follow ABI breaks.
# https://gitlab.gnome.org/GNOME/libxml2/-/issues/751
# This is of course ultimately good, but we can't recompile binja
# So let's just force it to use whatever NixOS has. It's Probably Fine™
preFixup = ''
patchelf $out/opt/binaryninja/plugins/lldb/lib/liblldb.so.* \
--replace-needed libxml2.so.2 libxml2.so
'';
dontWrapQtApps = true;
meta = {
mainProgram = "binaryninja";
};
}