From e15b079684b9003509e6b459278603de12c73b62 Mon Sep 17 00:00:00 2001 From: Alex Xiong Date: Thu, 12 Jan 2023 22:30:35 +0800 Subject: [PATCH] update nix to flake (#101) * update nix to flake * add nix sanity check cronjob --- .github/workflows/build_nix.yml | 28 ++++++ arithmetic/Cargo.toml | 14 ++- flake.lock | 148 +++++++++++++++++++++++++++++++ flake.nix | 84 ++++++++++++++++++ hyperplonk/Cargo.toml | 17 ++-- nix/grcov/default.nix | 28 ------ nix/nightly.nix | 25 ------ nix/nixpkgs.json | 4 - nix/nixpkgs.nix | 10 --- nix/oxalica_rust_overlay.json | 7 -- nix/pre-commit.nix | 34 ------- nix/update-nix | 27 ------ nix/update-rust-overlay | 5 -- nix/vagrant/.gitignore | 2 - nix/vagrant/README.md | 66 -------------- nix/vagrant/Vagrantfile | 36 -------- nix/vagrant/shell.nix | 7 -- nix/vagrant/test-nix-shell-guest | 20 ----- shell.nix | 58 +++--------- subroutines/Cargo.toml | 23 ++--- transcript/Cargo.toml | 6 +- util/Cargo.toml | 3 +- 22 files changed, 295 insertions(+), 357 deletions(-) create mode 100644 .github/workflows/build_nix.yml create mode 100644 flake.lock create mode 100644 flake.nix delete mode 100644 nix/grcov/default.nix delete mode 100644 nix/nightly.nix delete mode 100644 nix/nixpkgs.json delete mode 100644 nix/nixpkgs.nix delete mode 100644 nix/oxalica_rust_overlay.json delete mode 100644 nix/pre-commit.nix delete mode 100755 nix/update-nix delete mode 100755 nix/update-rust-overlay delete mode 100644 nix/vagrant/.gitignore delete mode 100644 nix/vagrant/README.md delete mode 100644 nix/vagrant/Vagrantfile delete mode 100644 nix/vagrant/shell.nix delete mode 100755 nix/vagrant/test-nix-shell-guest diff --git a/.github/workflows/build_nix.yml b/.github/workflows/build_nix.yml new file mode 100644 index 0000000..16db272 --- /dev/null +++ b/.github/workflows/build_nix.yml @@ -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 diff --git a/arithmetic/Cargo.toml b/arithmetic/Cargo.toml index 6959c66..17618a1 100644 --- a/arithmetic/Cargo.toml +++ b/arithmetic/Cargo.toml @@ -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] @@ -23,7 +20,7 @@ criterion = "0.3.0" [features] # default = [ "parallel", "print-trace" ] -default = [ "parallel" ] +default = ["parallel"] parallel = [ "rayon", "ark-std/parallel", @@ -34,8 +31,7 @@ print-trace = [ "ark-std/print-trace" ] - [[bench]] name = "mle_eval" path = "benches/bench.rs" -harness = false \ No newline at end of file +harness = false diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..0e08836 --- /dev/null +++ b/flake.lock @@ -0,0 +1,148 @@ +{ + "nodes": { + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1668681692, + "narHash": "sha256-Ht91NGdewz8IQLtWZ9LCeNXMSXHUss+9COoqu6JLmXU=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "009399224d5e398d03b22badca40a37ac85412a1", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-utils": { + "locked": { + "lastModified": 1667395993, + "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_2": { + "locked": { + "lastModified": 1667077288, + "narHash": "sha256-bdC8sFNDpT0HK74u9fUkpbf1MEzVYJ+ka7NXCdgBoaA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "6ee9ebb6b1ee695d2cacc4faa053a7b9baa76817", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_3": { + "locked": { + "lastModified": 1659877975, + "narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1668765800, + "narHash": "sha256-rC40+/W6Hio7b/RsY8SvQPKNx4WqNcTgfYv8cUMAvJk=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "52b2ac8ae18bbad4374ff0dd5aeee0fdf1aea739", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1665296151, + "narHash": "sha256-uOB0oxqxN9K7XGF1hcnY+PQnlQJ+3bP2vCn/+Ru/bbc=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "14ccaaedd95a488dd7ae142757884d8e125b3363", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "pre-commit-hooks": { + "inputs": { + "flake-utils": "flake-utils_2", + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1667992213, + "narHash": "sha256-8Ens8ozllvlaFMCZBxg6S7oUyynYx2v7yleC5M0jJsE=", + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "rev": "ebcbfe09d2bd6d15f68de3a0ebb1e4dcb5cd324b", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-compat": "flake-compat", + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs", + "pre-commit-hooks": "pre-commit-hooks", + "rust-overlay": "rust-overlay" + } + }, + "rust-overlay": { + "inputs": { + "flake-utils": "flake-utils_3", + "nixpkgs": "nixpkgs_2" + }, + "locked": { + "lastModified": 1668825399, + "narHash": "sha256-F2ro05D6tGMwSaOYeIediJq6X0ATD7JgWEG2TgOs9Wo=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "a705fe51ef5cdf932ff1cb342f0fe9e5d66f1b71", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..58b512c --- /dev/null +++ b/flake.nix @@ -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; + }; + } + ); +} diff --git a/hyperplonk/Cargo.toml b/hyperplonk/Cargo.toml index d1dd539..439ac35 100644 --- a/hyperplonk/Cargo.toml +++ b/hyperplonk/Cargo.toml @@ -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 @@ -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", @@ -55,4 +50,4 @@ print-trace = [ "ark-std/print-trace", "arithmetic/print-trace", "subroutines/print-trace" - ] \ No newline at end of file + ] diff --git a/nix/grcov/default.nix b/nix/grcov/default.nix deleted file mode 100644 index 51cb4f6..0000000 --- a/nix/grcov/default.nix +++ /dev/null @@ -1,28 +0,0 @@ -{ lib, rustToolchain, rustPlatform, fetchFromGitHub }: - -rustPlatform.buildRustPackage rec { - pname = "grcov"; - version = "v0.8.2"; - - # See https://nixos.org/manual/nixpkgs/stable/#using-community-rust-overlays - nativeBuildInputs = [ - rustToolchain - ]; - - doCheck = false; - - src = fetchFromGitHub { - owner = "mozilla"; - repo = pname; - rev = version; - sha256 = "t1Gj5u4MmXPbQ5jmO9Sstn7aXJ6Ge+AnsmmG2GiAGKE="; - }; - - cargoSha256 = "DRAUeDzNUMg0AGrqU1TdrqBZJw4A2o3YJB0MdwwzefQ="; - - meta = with lib; { - description = "grcov collects and aggregates code coverage information for multiple source files."; - homepage = "https://github.com/mozilla/grcov"; - license = licenses.mpl20; - }; -} diff --git a/nix/nightly.nix b/nix/nightly.nix deleted file mode 100644 index a054b8e..0000000 --- a/nix/nightly.nix +++ /dev/null @@ -1,25 +0,0 @@ -let - basePkgs = import ./nixpkgs.nix { }; - - rust_overlay = with basePkgs; import (fetchFromGitHub - (lib.importJSON ./oxalica_rust_overlay.json)); - - pkgs = import ./nixpkgs.nix { overlays = [ rust_overlay ]; }; - - nightlyToolchain = pkgs.rust-bin.selectLatestNightlyWith (toolchain: toolchain.minimal); - grcov = with pkgs; callPackage ./grcov { rustToolchain = nightlyToolchain; }; -in -with pkgs; - -mkShell { - buildInputs = [ - nightlyToolchain - grcov - ] ++ lib.optionals stdenv.isDarwin [ - darwin.apple_sdk.frameworks.Security - ]; - - shellHook = '' - export RUST_BACKTRACE=full - ''; -} diff --git a/nix/nixpkgs.json b/nix/nixpkgs.json deleted file mode 100644 index cc5cf51..0000000 --- a/nix/nixpkgs.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "url": "https://github.com/nixos/nixpkgs/archive/db8ab32efd3a4ad59044848d889480954e458f25.tar.gz", - "sha256": "1i7ayivjm3rx62qq263jjj55m0nzhn4b99wax25kw6a8zhhwcwjb" -} diff --git a/nix/nixpkgs.nix b/nix/nixpkgs.nix deleted file mode 100644 index ddfbdc4..0000000 --- a/nix/nixpkgs.nix +++ /dev/null @@ -1,10 +0,0 @@ -# Behaves like `` but pinned. Like ``, requires attrset for opt overlays. -attrs: -let - hostpkgs = import {}; - pinnedNixpkgs = hostpkgs.lib.importJSON ./nixpkgs.json; - nixpkgs = builtins.fetchTarball { - url = pinnedNixpkgs.url; - sha256 = pinnedNixpkgs.sha256; - }; -in import nixpkgs attrs diff --git a/nix/oxalica_rust_overlay.json b/nix/oxalica_rust_overlay.json deleted file mode 100644 index 98b0237..0000000 --- a/nix/oxalica_rust_overlay.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "owner": "oxalica", - "repo": "rust-overlay", - "rev": "9d7c777625640b70a4d211f62711fa316bca7176", - "sha256": "025bw59nl12jqf4nrvbn0a8xn03aj9bz54nvf1rb25zl2l1nkrnd", - "fetchSubmodules": true -} diff --git a/nix/pre-commit.nix b/nix/pre-commit.nix deleted file mode 100644 index 8d3552b..0000000 --- a/nix/pre-commit.nix +++ /dev/null @@ -1,34 +0,0 @@ -{ pkgs, ... }: - -let - nix-pre-commit-hooks = import (pkgs.fetchFromGitHub { - owner = "cachix"; - repo = "pre-commit-hooks.nix"; - rev = "ff9c0b459ddc4b79c06e19d44251daa8e9cd1746"; - sha256 = "jlsQb2y6A5dB1R0wVPLOfDGM0wLyfYqEJNzMtXuzCXw="; - }); -in -nix-pre-commit-hooks.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; - }; - # The hook "clippy" that ships with nix-precommit-hooks is outdated. - cargo-clippy = { - enable = true; - description = "Lint Rust code."; - entry = "cargo-clippy"; - files = "\\.rs$"; - pass_filenames = false; - }; - }; -} diff --git a/nix/update-nix b/nix/update-nix deleted file mode 100755 index e25d6d8..0000000 --- a/nix/update-nix +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/env nix-shell -#! nix-shell -i bash -p curl jq nix -# -# Updates nixpkgs.json to the latest or chosen nixpkgs revision -# -# Usage: ./update-nix -# ./update-nix $rev -# ./update-nix $owner $rev -# -# Arguments default to owner=nixos and rev=master and refer -# to the github owner of a nixpkgs fork and a git revision. -# -set -exo pipefail - -owner="nixos" - -if [ ! -z "$2" ]; then - owner="$1" - rev="$2" -else - rev="${1:-master}" -fi - -resolved_rev=$(curl "https://api.github.com/repos/${owner}/nixpkgs/commits?sha=${rev}" | jq -r 'first.sha') -url="https://github.com/${owner}/nixpkgs/archive/${resolved_rev}.tar.gz" -digest=$(nix-prefetch-url --unpack "$url") -echo "{\"url\": \"${url}\", \"sha256\": \"${digest}\"}" | jq '.' > nix/nixpkgs.json diff --git a/nix/update-rust-overlay b/nix/update-rust-overlay deleted file mode 100755 index df2349c..0000000 --- a/nix/update-rust-overlay +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env nix-shell -#! nix-shell -i bash -p nix-prefetch-github -set -exo pipefail - -nix-prefetch-github oxalica rust-overlay | tee nix/oxalica_rust_overlay.json diff --git a/nix/vagrant/.gitignore b/nix/vagrant/.gitignore deleted file mode 100644 index 51f8e48..0000000 --- a/nix/vagrant/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -hyperplonk/ -.vagrant diff --git a/nix/vagrant/README.md b/nix/vagrant/README.md deleted file mode 100644 index 96255fb..0000000 --- a/nix/vagrant/README.md +++ /dev/null @@ -1,66 +0,0 @@ -# Test nix-shell in vagrant VMs - -Set up a vagrant guest VM, and test the dev environment inside the guest. - -- Only tested on nixos host with _libvirt_ virtualization provider. -- Assumes that the host has an SSH agent. The agent is used for SSH auth inside - the guest. -- Upon creation (`vagrant up`) a copy of this local repo is rsynced to the - `/hyperplonk` directory in the guest. The tests are run against these files. To - see changes made to the code on the host run `vagrant reload` to re-sync the - source code from host to guest. - -## Available vagrant boxes -The following boxes are available: - - - `ubuntu`: `ubuntu20.04` + `nix` - - `ubuntu_rustup`: `ubuntu20.04` + `nix` + `rustup` - -More OSes/VMs can be added in the `Vagrantfile`. - -Append name of box after vagrant command to apply to a single box only - - vagrant up ubuntu_rustup - vagrant ssh ubuntu_rustup - -## Usage -Enable `libvrtd` on your host: -[ubuntu](https://ubuntu.com/server/docs/virtualization-libvirt), -[nixos](https://nixos.wiki/wiki/Libvirt). - -Make sure we are in the `libvirtd` group. - -Install `libvirt` vagrant plugin (not needed on nixos): - - vagrant plugin install vagrant-libvirt - -Activate nix-shell in this directory (or ensure vagrant is installed): - - nix-shell - -Start vm: - - vagrant up ubuntu - -There is a password prompt to add the insecure vagrant key to the agent. One can -supply an empty password once or cancel the prompt each time one runs `vagrant -ssh`. - -Run formatter, linter, tests inside a nix-shell environment inside the `ubuntu` -guest: - - vagrant ssh ubuntu -- -t /vagrant/test-nix-shell-guest - -This runs the `test-nix-shell-guest` script in this directory inside the vagrant -guest. - -Clean up with - - vagrant destroy ubuntu - -## Notes - -- After editing the Vagrantfile, `vagrant reload` will apply the changes. -- When making substantial changes or changing names of vagrant boxes I usually - have more luck with running `vagrant destroy` with the previous `Vagrantfile` - and then `vagrant up` again with the new `Vagrantfile`. diff --git a/nix/vagrant/Vagrantfile b/nix/vagrant/Vagrantfile deleted file mode 100644 index 6fab702..0000000 --- a/nix/vagrant/Vagrantfile +++ /dev/null @@ -1,36 +0,0 @@ -# -*- mode: ruby -*- -# vi: set ft=ruby : - -Vagrant.configure("2") do |config| - - config.vm.define "ubuntu" do |ubuntu| - ubuntu.vm.box = "generic/ubuntu2004" - $script = <<~SCRIPT - set -euxo pipefail - curl -L https://nixos.org/nix/install | sh - SCRIPT - ubuntu.vm.provision "shell", inline: $script, privileged: false - end - - config.vm.define "ubuntu_rustup" do |ubuntu| - ubuntu.vm.box = "generic/ubuntu2004" - $script = <<~SCRIPT - set -euxo pipefail - curl -L https://nixos.org/nix/install | sh - curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y - source $HOME/.cargo/env - rustup default stable-2021-06-17 - SCRIPT - ubuntu.vm.provision "shell", inline: $script, privileged: false - end - - config.ssh.forward_agent = true - config.vm.synced_folder ".", "/vagrant", disabled: false - config.vm.synced_folder "../..", "/hyperplonk", disabled: false, rsync__exclude: [".git/", "target"] - - - config.vm.provider "libvirt" do |v| - v.cpus = 4 - end - -end diff --git a/nix/vagrant/shell.nix b/nix/vagrant/shell.nix deleted file mode 100644 index 0a6b6cb..0000000 --- a/nix/vagrant/shell.nix +++ /dev/null @@ -1,7 +0,0 @@ -with import ../nixpkgs.nix { }; - -mkShell { - buildInputs = [ - vagrant - ]; -} diff --git a/nix/vagrant/test-nix-shell-guest b/nix/vagrant/test-nix-shell-guest deleted file mode 100755 index 81b9e50..0000000 --- a/nix/vagrant/test-nix-shell-guest +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env bash -set -euxo pipefail - -# vagrant "ssh + command" does not source, adding -- -t does not help -. $HOME/.nix-profile/etc/profile.d/nix.sh -if [ -f $HOME/.carg/env ]; then - source $HOME/.cargo/env -fi - -ssh-keyscan gitlab.com >> ~/.ssh/known_hosts -ssh -T git@gitlab.com - -cd /hyperplonk - -nix-shell --run "cargo-clippy" -nix-shell --run "cargo fmt -- --check" -nix-shell --run "cargo test --doc" -nix-shell --run "cargo test --release" - -echo "Ok!" diff --git a/shell.nix b/shell.nix index 993c4be..9eb132a 100644 --- a/shell.nix +++ b/shell.nix @@ -1,45 +1,13 @@ -let - basePkgs = import ./nix/nixpkgs.nix { }; - - rust_overlay = with basePkgs; import (fetchFromGitHub - (lib.importJSON ./nix/oxalica_rust_overlay.json)); - - pkgs = import ./nix/nixpkgs.nix { overlays = [ rust_overlay ]; }; - - nightlyToolchain = pkgs.rust-bin.selectLatestNightlyWith (toolchain: toolchain.minimal.override { - extensions = [ "rustfmt" ]; - }); - - stableToolchain = pkgs.rust-bin.stable."1.56.1".minimal.override { - extensions = [ "clippy" "llvm-tools-preview" "rust-src" ]; - }; - - pre-commit-check = pkgs.callPackage ./nix/pre-commit.nix { }; -in -with pkgs; - -mkShell { - buildInputs = [ - argbash - openssl - pkgconfig - git - - stableToolchain - nightlyToolchain - - ] ++ 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 - ${pre-commit-check.shellHook} - ''; -} +(import + ( + let + lock = builtins.fromJSON (builtins.readFile ./flake.lock); + in + fetchTarball { + url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz"; + sha256 = lock.nodes.flake-compat.locked.narHash; + } + ) + { + src = ./.; + }).shellNix diff --git a/subroutines/Cargo.toml b/subroutines/Cargo.toml index 3599eaa..83acd50 100644 --- a/subroutines/Cargo.toml +++ b/subroutines/Cargo.toml @@ -2,28 +2,23 @@ name = "subroutines" version = "0.1.0" edition = "2021" - # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] - -ark-ff = { version = "^0.3.0", default-features = false } -ark-std = { version = "^0.3.0", default-features = false } +arithmetic = { path = "../arithmetic" } +ark-bls12-381 = { version = "0.3.0", default-features = false, features = [ "curve" ] } 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 } -ark-bls12-381 = { version = "0.3.0", default-features = false, features = [ "curve" ] } - -rand_chacha = { 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 } +ark-std = { version = "^0.3.0", default-features = false } derivative = { version = "2", features = ["use_core"] } +displaydoc = { version = "0.2.3", default-features = false } itertools = { version = "0.10.4", optional = true } - +rand_chacha = { version = "0.3.0", default-features = false } +rayon = { version = "1.5.2", default-features = false, optional = true } transcript = { path = "../transcript" } -arithmetic = { path = "../arithmetic" } util = { path = "../util" } - # # Benchmarks # [[bench]] # name = "poly-iop-benches" @@ -38,7 +33,7 @@ harness = false [features] # default = [ "parallel", "print-trace" ] -default = [ "parallel" ] +default = ["parallel"] # extensive sanity checks that are useful for debugging extensive_sanity_checks = [ ] parallel = [ @@ -54,4 +49,4 @@ parallel = [ print-trace = [ "arithmetic/print-trace", "ark-std/print-trace", - ] \ No newline at end of file + ] diff --git a/transcript/Cargo.toml b/transcript/Cargo.toml index 91c7c2f..c12ee3d 100644 --- a/transcript/Cargo.toml +++ b/transcript/Cargo.toml @@ -2,16 +2,12 @@ name = "transcript" version = "0.1.0" edition = "2021" - # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -merlin = { version = "3.0.0", default-features = false } - - ark-ff = { version = "^0.3.0", default-features = false } ark-serialize = { version = "^0.3.0", default-features = false } ark-std = { version = "^0.3.0", default-features = false } - displaydoc = { version = "0.2.3", default-features = false } +merlin = { version = "3.0.0", default-features = false } diff --git a/util/Cargo.toml b/util/Cargo.toml index 45ad040..8b7d419 100644 --- a/util/Cargo.toml +++ b/util/Cargo.toml @@ -2,7 +2,6 @@ name = "util" version = "0.1.0" edition = "2021" - # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] @@ -10,4 +9,4 @@ rayon = { version = "1.5.0", optional = true } [features] default = [] -parallel = [ "rayon" ] \ No newline at end of file +parallel = ["rayon"]