-
Notifications
You must be signed in to change notification settings - Fork 11
/
flake.nix
executable file
·123 lines (97 loc) · 3.71 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
120
121
122
123
{
description = "build halo2 backend";
inputs = {
nixpkgs = {
url = "github:NixOS/nixpkgs/nixpkgs-unstable";
};
flake-utils = {
url = "github:numtide/flake-utils";
};
flake-compat = {
url = "github:edolstra/flake-compat";
flake = false;
};
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs = {
nixpkgs.follows = "nixpkgs";
flake-utils.follows = "flake-utils";
};
};
crane = {
url = "github:ipetkov/crane";
inputs = {
nixpkgs.follows = "nixpkgs";
flake-utils.follows = "flake-utils";
flake-compat.follows = "flake-compat";
rust-overlay.follows = "rust-overlay";
};
};
};
outputs = { self, nixpkgs, flake-utils, rust-overlay, crane, ... }:
flake-utils.lib.eachDefaultSystem (system:
let
overlays = [ (import rust-overlay) ];
pkgs = import nixpkgs {
inherit system overlays;
};
rust_toolchain = pkgs.rust-bin.nightly."2022-10-28".default.override {
extensions = [ "rust-src" ];
targets = [ "wasm32-unknown-unknown" ]
++ pkgs.lib.optional (pkgs.hostPlatform.isx86_64 && pkgs.hostPlatform.isLinux) "x86_64-unknown-linux-gnu"
++ pkgs.lib.optional (pkgs.hostPlatform.isAarch64 && pkgs.hostPlatform.isLinux) "aarch64-unknown-linux-gnu"
++ pkgs.lib.optional (pkgs.hostPlatform.isx86_64 && pkgs.hostPlatform.isDarwin) "x86_64-apple-darwin"
++ pkgs.lib.optional (pkgs.hostPlatform.isAarch64 && pkgs.hostPlatform.isDarwin) "aarch64-apple-darwin";
};
crane_lib = (crane.mkLib pkgs).overrideToolchain rust_toolchain;
common_args = {
src = crane_lib.cleanCargoSource (crane_lib.path ./.);
};
extraBuildInputs = pkgs.lib.optionals pkgs.stdenv.isDarwin [
pkgs.libiconv
pkgs.darwin.apple_sdk.frameworks.Security
];
noir_halo2_pse_naitive_args = common_args // {
pname = "noir_halo2_backend_pse_naitive";
buildInputs = [] ++ extraBuildInputs;
};
noir_halo2_pse_wasm_args = common_args // {
pname = "noir_halo2_backend_pse_wasm";
cargoExtraArgs = "--target wasm32-unknown-unknown";
buildInputs = [] ++ extraBuildInputs;
};
noir_halo2_pse_naitive_cargo_artifacts = crane_lib.buildDepsOnly noir_halo2_pse_naitive_args;
noir_halo2_pse_wasm_cargo_artifacts = crane_lib.buildDepsOnly noir_halo2_pse_wasm_args;
noir_halo2_pse_naitive = crane_lib.buildPackage (noir_halo2_pse_naitive_args // {
cargoArtifacts = noir_halo2_pse_naitive_cargo_artifacts;
doCheck = false;
});
noir_halo2_pse_wasm = crane_lib.buildPackage (noir_halo2_pse_wasm_args // {
cargoArtifacts = noir_halo2_pse_wasm_cargo_artifacts;
doCheck = false;
});
in
{
checks = {
cargo-fmt = crane_lib.cargoFmt (noir_halo2_pse_naitive_args // {
cargoArtifacts = noir_halo2_pse_naitive_cargo_artifacts;
});
cargo-clippy = crane_lib.cargoClippy (noir_halo2_pse_naitive_args // {
cargoArtifacts = noir_halo2_pse_naitive_cargo_artifacts;
cargoClippyExtraArgs = "--all-targets -- --deny warnings";
});
};
packages = {
default = noir_halo2_pse_naitive;
# wasm not working with nix at the moment
wasm = noir_halo2_pse_wasm;
};
devShells.default = pkgs.mkShell ( {
inputsFrom = builtins.attrValues self.checks.${system};
nativeBuildInputs = with pkgs; [
git
rust_toolchain
];
});
});
}