Skip to content

Commit

Permalink
migrate to nix flake (#126)
Browse files Browse the repository at this point in the history
  • Loading branch information
alxiong authored Oct 21, 2022
1 parent ff43209 commit 64f55be
Show file tree
Hide file tree
Showing 24 changed files with 374 additions and 426 deletions.
5 changes: 5 additions & 0 deletions .license-header
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Copyright (c) 2022 Espresso Systems (espressosys.com)
This file is part of the Jellyfish library.

You should have received a copy of the MIT License
along with the Jellyfish library. If not, see <https://mit-license.org/>.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[workspace]
members = [
"plonk",
"relation",
"primitives",
"relation",
"utilities",
"utilities_derive",
]
14 changes: 6 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Jellyfish cryptographic library

![example workflow](https://github.com/EspressoSystems/jellyfish/actions/workflows/build.yml/badge.svg)
![Crates.io (version)](https://img.shields.io/crates/dv/jf-plonk/0.1.0)
![GitHub](https://img.shields.io/github/license/EspressoSystems/jellyfish)
Expand All @@ -8,7 +9,7 @@
**DISCLAIMER:** This software is provided "as is" and its security has not been externally audited. Use at your own risk.

## Chatroom

For general discussions on Jellyfish PLONK, please join our [Discord channel](https://discord.gg/GJa4gznGfU).

## Development environment setup
Expand Down Expand Up @@ -100,15 +101,12 @@ To format your code run

### Updating non-cargo dependencies

- To update the [nix packages](https://github.com/NixOS/nixpkgs) run `./nix/update-nix`.
- To update the [rust overlay](https://github.com/oxalica/rust-overlay) run
`./nix/update-rust-overlay`.

To use the updates enter a new `nix-shell`.
Run `nix flake update` if you would like to pin other version edit `flake.nix`
beforehand. Commit the lock file when happy.

### Testing the nix-shell dev environment on other platforms
To update only a single input specify it as argument, for example

Refer to the [nix/vagrant](./nix/vagrant/) directory.
nix flake update github:oxalica/rust-overlay

### Benchmarks

Expand Down
160 changes: 160 additions & 0 deletions flake.lock

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

98 changes: 98 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# Copyright (c) 2022 Espresso Systems (espressosys.com)
# This file is part of the Jellyfish library.

# You should have received a copy of the MIT License
# along with the Jellyfish library. If not, see <https://mit-license.org/>.

{
description = "Jellyfish 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";

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;
};
license-header-c-style = {
enable = true;
description =
"Ensure files with c-style comments have license header";
entry = ''
insert_license --license-filepath .license-header --comment-style "//"'';
types_or = [ "rust" ];
pass_filenames = true;
};
};
};
};
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;
};
}
);
}
28 changes: 0 additions & 28 deletions nix/grcov/default.nix

This file was deleted.

25 changes: 0 additions & 25 deletions nix/nightly.nix

This file was deleted.

4 changes: 0 additions & 4 deletions nix/nixpkgs.json

This file was deleted.

10 changes: 0 additions & 10 deletions nix/nixpkgs.nix

This file was deleted.

7 changes: 0 additions & 7 deletions nix/oxalica_rust_overlay.json

This file was deleted.

Loading

0 comments on commit 64f55be

Please sign in to comment.