Skip to content

Commit 9e1611a

Browse files
committed
Initial Commit
0 parents  commit 9e1611a

File tree

8 files changed

+263
-0
lines changed

8 files changed

+263
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
result
2+

LICENSE.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Unlicense
2+
3+
This is free and unencumbered software released into the public domain.
4+
5+
Anyone is free to copy, modify, publish, use, compile, sell, or
6+
distribute this software, either in source code form or as a compiled
7+
binary, for any purpose, commercial or non-commercial, and by any
8+
means.
9+
10+
In jurisdictions that recognize copyright laws, the author or authors
11+
of this software dedicate any and all copyright interest in the
12+
software to the public domain. We make this dedication for the benefit
13+
of the public at large and to the detriment of our heirs and
14+
successors. We intend this dedication to be an overt act of
15+
relinquishment in perpetuity of all present and future rights to this
16+
software under copyright law.
17+
18+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
21+
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
22+
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
23+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24+
OTHER DEALINGS IN THE SOFTWARE.
25+
26+
For more information, please refer to <http://unlicense.org/>

README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Nix flake for Binary Ninja
2+
This is an unofficial, experimental Nix flake for running Binary Ninja on NixOS.
3+
4+
More testing is needed; currently only `x86-64_linux` is tested, and only a bit.
5+
Additionally, more variants (e.g. an FHS variant) might be desirable.
6+
7+
## License
8+
9+
### Binary Ninja
10+
11+
Please note that Binary Ninja is not free software. This flake does not grant
12+
you a license to use Binary Ninja.
13+
14+
When using the `binary-ninja-free` package, a copy of Binary Ninja will be
15+
downloaded from the Vector 35 servers. Prior to using this flake, you must
16+
agree to the
17+
[Binary Ninja Free License terms](https://docs.binary.ninja/about/license.html#free-license).
18+
For all other editions, you must acquire a current copy of Binary Ninja for your
19+
platform and add it to the Nix store, using, for example, the following command:
20+
21+
```console
22+
$ nix-store --add-fixed sha256 ./binary-linux-commercial.zip
23+
```
24+
25+
Of course, your usage of personal, commercial and enterprise Binary Ninja is
26+
governed by your respective agreements.
27+
28+
### Nix Flake
29+
30+
This Nix flake is in the public domain, or in jurisdictions where this is not
31+
recognized, is available under the terms of the Unlicense. See LICENSE.md for
32+
more information.

flake.lock

Lines changed: 60 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
description = "Flake for building Binary Ninja";
3+
4+
inputs = {
5+
nixpkgs.url = "github:nixos/nixpkgs";
6+
flake-utils.url = "github:numtide/flake-utils";
7+
};
8+
9+
outputs =
10+
{ nixpkgs, flake-utils, ... }:
11+
flake-utils.lib.eachDefaultSystem (
12+
system:
13+
let
14+
pkgs = nixpkgs.legacyPackages.${system};
15+
lib = pkgs.lib;
16+
sources = pkgs.callPackage ./sources.nix { };
17+
editions = lib.mapAttrs' (binaryNinjaEdition: value: {
18+
name = "binary-ninja-${binaryNinjaEdition}";
19+
value = pkgs.callPackage ./package.nix { inherit binaryNinjaEdition; };
20+
}) sources.editions;
21+
packages = editions // {
22+
default = editions.binary-ninja-free;
23+
};
24+
in
25+
{
26+
inherit packages;
27+
}
28+
);
29+
}

hashes.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.nix

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
{
2+
stdenv,
3+
callPackage,
4+
autoPatchelfHook,
5+
makeWrapper,
6+
requireFile,
7+
unzip,
8+
libGL,
9+
glib,
10+
fontconfig,
11+
xorg,
12+
dbus,
13+
xkeyboard_config,
14+
libxkbcommon,
15+
wayland-scanner,
16+
kdePackages,
17+
18+
binaryNinjaEdition ? "personal",
19+
}:
20+
let
21+
sources = callPackage ./sources.nix { };
22+
platformSources = sources.editions.${binaryNinjaEdition};
23+
source =
24+
if builtins.hasAttr stdenv.hostPlatform.system platformSources then
25+
platformSources.${stdenv.hostPlatform.system}
26+
else
27+
throw "No source for system ${stdenv.hostPlatform.system}";
28+
in
29+
stdenv.mkDerivation {
30+
pname = "binary-ninja";
31+
inherit (sources) version;
32+
nativeBuildInputs = [
33+
makeWrapper
34+
autoPatchelfHook
35+
kdePackages.wrapQtAppsHook
36+
];
37+
buildInputs = [
38+
unzip
39+
libGL
40+
glib
41+
fontconfig
42+
xorg.libXi
43+
xorg.libXrender
44+
xorg.xcbutilimage
45+
xorg.xcbutilrenderutil
46+
kdePackages.qtbase
47+
kdePackages.qtdeclarative
48+
libxkbcommon
49+
dbus
50+
wayland-scanner.out
51+
];
52+
src = source;
53+
buildPhase = ":";
54+
installPhase = ''
55+
runHook preInstall
56+
57+
mkdir -p $out/bin
58+
mkdir -p $out/opt
59+
cp -r * $out/opt
60+
chmod +x $out/opt/binaryninja
61+
makeWrapper $out/opt/binaryninja \
62+
$out/bin/binaryninja \
63+
--prefix "QT_XKB_CONFIG_ROOT" ":" "${xkeyboard_config}/share/X11/xkb"
64+
65+
runHook postInstall
66+
'';
67+
}

sources.nix

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
{
2+
lib,
3+
requireFile,
4+
fetchurl,
5+
}:
6+
let
7+
data = builtins.fromJSON (builtins.readFile ./hashes.js);
8+
version = lib.head (lib.splitString " " data.version);
9+
editions = [
10+
"free"
11+
"personal"
12+
"commercial"
13+
"enterprise"
14+
];
15+
mkFreeSource =
16+
name:
17+
fetchurl {
18+
url = "https://cdn.binary.ninja/installers/${name}";
19+
sha256 = data.hashes.${name};
20+
};
21+
mkSource =
22+
name:
23+
requireFile {
24+
inherit name;
25+
url = "https://binary.ninja/recover/";
26+
sha256 = data.hashes.${name};
27+
};
28+
mkEditionNames = edition: {
29+
aarch64-darwin = "binaryninja_${edition}_macosx.dmg";
30+
aarch64-linux = "binaryninja_${edition}_linux_arm.zip";
31+
x86_64-darwin = "binaryninja_${edition}_macosx.dmg";
32+
x86_64-linux = "binaryninja_${edition}_linux.zip";
33+
x86_64-windows = "binaryninja_${edition}_win64.exe";
34+
};
35+
in
36+
{
37+
inherit version;
38+
editions = builtins.listToAttrs (
39+
map (edition: {
40+
name = edition;
41+
value = lib.mapAttrs (name: file: if edition == "free" then mkFreeSource file else mkSource file) (
42+
mkEditionNames edition
43+
);
44+
}) editions
45+
);
46+
}

0 commit comments

Comments
 (0)