forked from AztecProtocol/barretenberg
-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
94 lines (84 loc) · 3.09 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
{
description =
"Barretenberg: C++ cryptographic library, BN254 elliptic curve library, and PLONK SNARK prover";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-22.11";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils }:
let
barretenbergOverlay = final: prev: {
barretenberg = prev.callPackage ./barretenberg.nix { };
barretenberg-wasm = prev.callPackage ./barretenberg-wasm.nix { };
barretenberg-transcript00 = prev.fetchurl {
url = "http://aztec-ignition.s3.amazonaws.com/MAIN%20IGNITION/monomial/transcript00.dat";
sha256 = "sha256-D5SzlCb1pX0aF3QmJPfTFwoy4Z1sXhbyAigUOdvkhpU=";
};
};
in
flake-utils.lib.eachDefaultSystem
(system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [ barretenbergOverlay ];
};
optional = pkgs.lib.lists.optional;
crossTargets = builtins.listToAttrs
(
[ ] ++ optional (pkgs.hostPlatform.isx86_64 && pkgs.hostPlatform.isLinux) {
name = "cross-aarch64";
value = pkgs.pkgsCross.aarch64-multiplatform-musl.pkgsLLVM.barretenberg;
} ++ optional (pkgs.hostPlatform.isx86_64 && pkgs.hostPlatform.isDarwin) {
name = "cross-aarch64";
value = pkgs.pkgsCross.aarch64-darwin.barretenberg;
}
);
shellDefaults = {
nativeBuildInputs = [
pkgs.starship
pkgs.llvmPackages_15.llvm
];
shellHook = ''
eval "$(starship init bash)"
'';
};
in
rec {
packages = {
llvm15 = pkgs.barretenberg.override {
llvmPackages = pkgs.llvmPackages_15;
};
llvm16 = pkgs.barretenberg.override {
llvmPackages = pkgs.llvmPackages_16;
};
wasm32 = pkgs.barretenberg-wasm;
default = packages.llvm15;
} // crossTargets;
# Provide legacyPackages with our overlay so we can run
# > `nix build .#pkgsCross.aarch64-multiplatform.barretenberg`
# Ref https://discourse.nixos.org/t/how-do-i-cross-compile-a-flake/12062/12
legacyPackages = import nixpkgs {
inherit system;
overlays = [ barretenbergOverlay ];
crossOverlays = [ barretenbergOverlay ];
};
devShells = {
default = pkgs.mkShell.override { stdenv = packages.default.stdenv; }
({
inputsFrom =
[ packages.default ];
} // shellDefaults);
wasm32 = pkgs.mkShell.override
{
# TODO: This derivations forces wasi-sdk 12 so the stdenv will have the wrong tools
stdenv = packages.wasm32.stdenv;
}
({
inputsFrom = [ packages.wasm32 ];
} // shellDefaults);
};
}) // {
overlays.default = barretenbergOverlay;
};
}