forked from ton-blockchain/ton
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathflake.nix
119 lines (113 loc) · 3.85 KB
/
flake.nix
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
{
inputs = {
nixpkgs-stable.url = "github:nixos/nixpkgs/nixos-23.05";
nixpkgs-trunk.url = "github:nixos/nixpkgs";
flake-compat = {
url = "github:edolstra/flake-compat";
flake = false;
};
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs-stable, nixpkgs-trunk, flake-compat, flake-utils }:
let
ton = { host, system, kind }:
let
p = host.hostPlatform;
pkgname =
if p.isLinux then
if p.isx86 then "linux-x86-64-${kind}.nix"
else if p.isAarch64 then "linux-arm64-${kind}.nix"
else throw "unsupported platform"
else if p.isDarwin then "macos-${kind}.nix"
else throw "unsupported platform";
pkg = ./assembly/nix/${pkgname};
in
import pkg {
pkgs = host;
inherit system;
src = host.nix-gitignore.gitignoreRecursiveSource [ ] ./.;
};
tonPython = ton: python: ton.overrideAttrs (previousAttrs:
{
buildInputs = previousAttrs.buildInputs ++ [ python ];
cmakeFlags = previousAttrs.cmakeFlags ++ [
"-DTON_USE_PYTHON=1"
"-DPython_ROOT_DIR=${python}"
"-DPython_EXECUTABLE=${python.pythonForBuild.interpreter}"
"-DPython_INCLUDE_DIR=${python}/include/python${python.pythonVersion}"
"-DPython_LIBRARY=${python}/lib/python${python.pythonVersion}"
];
doCheck = false;
ninjaFlags = "python_ton";
installPhase = ''
runHook preInstall
cmake --install . --component tvm-python
runHook postInstall
'';
outputs = [ "out" ];
});
hostPkgs = system:
import nixpkgs-stable {
inherit system;
overlays = [ ];
};
in
with flake-utils.lib;
(nixpkgs-stable.lib.recursiveUpdate
(eachSystem (with system; [ x86_64-linux aarch64-linux ]) (system:
let
host = hostPkgs system;
tonk = kind: ton {
inherit host;
inherit system;
inherit kind;
};
tonOldGlibcPython = ton: python: (tonPython ton python).overrideAttrs (previousAttrs: {
dontPatchELF = true;
preFixup = ''
patchelf --remove-rpath $out/*/*
'';
});
in
rec {
packages = rec {
ton-static = tonk "static";
ton-tonlib = tonk "tonlib";
ton-python-39 = tonOldGlibcPython ton-tonlib host.python39;
ton-python-310 = tonOldGlibcPython ton-tonlib host.python310;
ton-python-311 = tonOldGlibcPython ton-tonlib host.python311;
};
devShells.default =
host.mkShell {
inputsFrom = [ packages.ton-tonlib ];
shellHook = ''
export cmakeFlags="${host.lib.concatStringsSep " " packages.ton-tonlib.cmakeFlags}"
'';
};
}))
(eachSystem (with system; [ x86_64-darwin aarch64-darwin ]) (system:
let
host = hostPkgs system;
tonk = kind: ton {
inherit host;
inherit system;
inherit kind;
};
in
rec {
packages = rec {
ton-static = tonk "static";
ton-tonlib = tonk "tonlib";
ton-python-39 = tonPython ton-static host.python39;
ton-python-310 = tonPython ton-static host.python310;
ton-python-311 = tonPython ton-static host.python311;
};
devShells.default =
host.mkShell {
inputsFrom = [ packages.ton-static ];
shellHook = ''
export cmakeFlags="${host.lib.concatStringsSep " " packages.ton-tonlib.cmakeFlags}"
'';
};
})));
}