forked from unionlabs/union
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaptos.nix
114 lines (96 loc) · 2.67 KB
/
aptos.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
_: {
perSystem =
{
self',
lib,
unstablePkgs,
pkgs,
system,
config,
rust,
crane,
stdenv,
dbg,
...
}:
let
throwBadSystem = throw "aptos cannot be built on system `${system}`";
CARGO_BUILD_TARGET =
if system == "aarch64-linux" then
"aarch64-unknown-linux-musl"
else if system == "x86_64-linux" then
"x86_64-unknown-linux-musl"
else if system == "aarch64-darwin" then
"aarch64-apple-darwin"
else if system == "x86_64-darwin" then
"x86_64-apple-darwin"
else
throwBadSystem;
rustToolchain = rust.mkNightly {
channel = "1.78.0";
targets = [ CARGO_BUILD_TARGET ];
};
craneLib = crane.lib.overrideToolchain rustToolchain;
aptos = craneLib.buildPackage rec {
pname = "movement";
version = "d34bb3e3dad03241967c0263a6f1fcfe6bccb7d7";
buildInputs = [
pkgs.pkg-config
pkgs.openssl
pkgs.systemd
config.treefmt.build.programs.rustfmt
pkgs.elfutils
pkgs.lld
pkgs.mold
] ++ (lib.optionals pkgs.stdenv.isDarwin [ pkgs.darwin.apple_sdk.frameworks.Security ]);
nativeBuildInputs = [
pkgs.clang
];
cargoExtraArgs = "-p movement";
LIBCLANG_PATH = "${pkgs.llvmPackages_14.libclang.lib}/lib";
CARGO_PROFILE = "cli";
# CARGO_BUILD_RUSTFLAGS = "-C target-feature=+crt-static";
src = builtins.fetchGit {
url = "https://github.com/aeryz/aptos-core";
ref = "movement";
rev = version;
};
doCheck = false;
};
movement = pkgs.writeShellApplication {
name = "movement";
runtimeInputs = [
pkgs.systemd
aptos
];
text = ''
out=$(mktemp -d)
cp ${aptos}/bin/movement "$out"
chmod +x "$out/movement"
# TODO(aeryz): not having a good time but for some reason, I can't produce a static bin
LD_LIBRARY_PATH="${
pkgs.lib.makeLibraryPath [
pkgs.openssl
pkgs.systemd
pkgs.gcc13Stdenv.cc.cc
]
}" "$out/movement" "$@"
'';
};
movefmt = craneLib.buildPackage rec {
pname = "movefmt";
version = "3201309e4cce72205994e32a4d45d1447db705e5";
src = builtins.fetchGit {
url = "https://github.com/movebit/movefmt";
ref = "develop";
rev = version;
};
doCheck = false;
};
in
{
packages = {
inherit movement movefmt;
};
};
}