Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update nix to flake #101

Merged
merged 2 commits into from
Jan 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions .github/workflows/build_nix.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Build with Nix Workflow

on:
schedule:
- cron: '0 0 * * 1'
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 120
steps:
- uses: styfle/cancel-workflow-action@0.11.0
name: Cancel Outdated Builds
with:
all_but_latest: true
access_token: ${{ github.token }}

- name: Install Nix
uses: cachix/install-nix-action@v18

- name: Checkout Repository
uses: actions/checkout@v3

# sanity check that repository builds with nix
- name: Build
run: |
nix develop -c cargo build --all-targets --release --workspace
14 changes: 5 additions & 9 deletions arithmetic/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,16 @@
name = "arithmetic"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]

ark-bls12-381 = { version = "0.3.0", default-features = false, features = [ "curve" ] }
ark-ff = { version = "^0.3.0", default-features = false }
ark-std = { version = "^0.3.0", default-features = false }
ark-poly = { version = "^0.3.0", default-features = false }
ark-serialize = { version = "^0.3.0", default-features = false }
ark-bls12-381 = { version = "0.3.0", default-features = false, features = [ "curve" ] }

rand_chacha = { version = "0.3.0", default-features = false }
ark-std = { version = "^0.3.0", default-features = false }
displaydoc = { version = "0.2.3", default-features = false }
rand_chacha = { version = "0.3.0", default-features = false }
rayon = { version = "1.5.2", default-features = false, optional = true }

[dev-dependencies]
Expand All @@ -23,7 +20,7 @@ criterion = "0.3.0"

[features]
# default = [ "parallel", "print-trace" ]
default = [ "parallel" ]
default = ["parallel"]
parallel = [
"rayon",
"ark-std/parallel",
Expand All @@ -34,8 +31,7 @@ print-trace = [
"ark-std/print-trace"
]


[[bench]]
name = "mle_eval"
path = "benches/bench.rs"
harness = false
harness = false
148 changes: 148 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

84 changes: 84 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
{
description = "Hyperplonk dev env";

inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
inputs.flake-utils.url = "github:numtide/flake-utils"; # for dedup

# allow shell.nix alongside flake.nix
inputs.flake-compat.url = "github:edolstra/flake-compat";
inputs.flake-compat.flake = false;

inputs.rust-overlay.url = "github:oxalica/rust-overlay";
inputs.pre-commit-hooks.url = "github:cachix/pre-commit-hooks.nix";
inputs.pre-commit-hooks.inputs.nixpkgs.follows = "nixpkgs";

outputs = { self, nixpkgs, flake-utils, flake-compat, rust-overlay, pre-commit-hooks, ... }:
flake-utils.lib.eachDefaultSystem (system:
let
overlays = [ (import rust-overlay) ];
pkgs = import nixpkgs { inherit system overlays; };
nightlyToolchain = pkgs.rust-bin.selectLatestNightlyWith
(toolchain: toolchain.minimal.override { extensions = [ "rustfmt" ]; });

stableToolchain = pkgs.rust-bin.stable.latest.minimal.override {
extensions = [ "clippy" "llvm-tools-preview" "rust-src" ];
};
in with pkgs;
{
check = {
pre-commit-check = pre-commit-hooks.lib.${system}.run {
src = ./.;
hooks = {
check-format = {
enable = true;
files = "\\.rs$";
entry = "cargo fmt -- --check";
};
doctest = {
enable = true;
entry = "cargo test --doc";
files = "\\.rs$";
pass_filenames = false;
};
cargo-clippy = {
enable = true;
description = "Lint Rust code.";
entry = "cargo-clippy --workspace -- -D warnings";
files = "\\.rs$";
pass_filenames = false;
};
cargo-sort = {
enable = true;
description = "Ensure Cargo.toml are sorted";
entry = "cargo sort -w";
pass_filenames = false;
};
};
};
};
devShell = mkShell {
buildInputs = [
argbash
openssl
pkgconfig
git

stableToolchain
nightlyToolchain
cargo-sort

] ++ lib.optionals stdenv.isDarwin [ darwin.apple_sdk.frameworks.Security ];

shellHook = ''
export RUST_BACKTRACE=full
export PATH="$PATH:$(pwd)/target/debug:$(pwd)/target/release"

# Ensure `cargo fmt` uses `rustfmt` from nightly.
export RUSTFMT="${nightlyToolchain}/bin/rustfmt"
''
# install pre-commit hooks
+ self.check.${system}.pre-commit-check.shellHook;
};
}
);
}
17 changes: 6 additions & 11 deletions hyperplonk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,21 @@
name = "hyperplonk"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]

ark-std = { version = "^0.3.0", default-features = false }
arithmetic = { path = "../arithmetic" }
ark-ec = { version = "^0.3.0", default-features = false }
ark-ff = { version = "^0.3.0", default-features = false }
ark-poly = { version = "^0.3.0", default-features = false }
ark-serialize = { version = "^0.3.0", default-features = false, features = [ "derive" ] }

ark-std = { version = "^0.3.0", default-features = false }
displaydoc = { version = "0.2.3", default-features = false }

rayon = { version = "1.5.2", default-features = false, optional = true }
subroutines = { path = "../subroutines" }
transcript = { path = "../transcript" }
arithmetic = { path = "../arithmetic" }
util = { path = "../util" }

rayon = { version = "1.5.2", default-features = false, optional = true }

[dev-dependencies]
ark-bls12-381 = { version = "0.3.0", default-features = false, features = [ "curve" ] }
# Benchmarks
Expand All @@ -34,8 +29,8 @@ harness = false
# default = [ ]
# default = [ "parallel" ]
# default = [ "parallel", "print-trace" ]
default = [ "parallel", "extensive_sanity_checks" ]
bench = [ "parallel" ]
default = ["parallel", "extensive_sanity_checks"]
bench = ["parallel"]
# extensive sanity checks that are useful for debugging
extensive_sanity_checks = [
"subroutines/extensive_sanity_checks",
Expand All @@ -55,4 +50,4 @@ print-trace = [
"ark-std/print-trace",
"arithmetic/print-trace",
"subroutines/print-trace"
]
]
28 changes: 0 additions & 28 deletions nix/grcov/default.nix

This file was deleted.

Loading