Skip to content
This repository has been archived by the owner on Sep 16, 2024. It is now read-only.

Commit

Permalink
add flake template, update README
Browse files Browse the repository at this point in the history
Co-authored-by: Marijan Petričević <marijan.petricevic94@gmail.com>
  • Loading branch information
quinn-dougherty and marijanp committed Jan 9, 2024
1 parent fcbfbd4 commit cee0b8b
Show file tree
Hide file tree
Showing 13 changed files with 2,328 additions and 53 deletions.
71 changes: 18 additions & 53 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,63 +2,28 @@

## Getting Started

Start with adding `risc0pkgs` as an input in your top-level `flake.nix` and define an initial package output (no existing sources/`src` required yet) as well as a dev-shell output:
It's recommended to get started by initializing your project using the default template:

```nix
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
risc0pkgs.url = "github:cspr-rad/risc0pkgs";
risc0pkgs.inputs.nixpkgs.follows = "nixpkgs";
};
outputs = { self, nixpkgs, risc0pkgs ... }:
let
system = "x86_64-linux";
pkgs = nixpkgs.legacyPackages.${system};
in
{
packages.${system}.risc0package = risc0pkgs.lib.${system}.buildRisc0Package {
pname = "risc0package";
version = "0.0.1";
src = ./.;
doCheck = false;
cargoSha256 = pkgs.lib.fakeSha256;
};
```sh
mkdir risc0-workspace
cd risc0-workspace

devShells.${system}.default = pkgs.mkShell {
RISC0_DEV_MODE = 1;
inputsFrom = [ self.packages.${system}.risc0package ];
nativeBuildInputs = [
risc0pkgs.packages.${system}.r0vm
];
};
};
}
nix flake init -t github:cspr-rad/risc0pkgs

git init
git add -A

nix build .#risc0prover
```

Enter the dev-shell by executing `nix develop` in your terminal and follow the steps explained in the RISC zero quick start guide: [2. Create a New Project](https://dev.risczero.com/api/zkvm/quickstart#2-create-a-new-project).
Note: Change the `system` to `aarch64-darwin` if you're on macOS.

Inside the dev-shell, you can execute `cargo run` just like explained in the quick start guide.
If you want to integrate `risc0` into your existing flake, see `./templates/default/flake.nix`.

Once you've created a risc0 project as explained in [2. Create a New Project](https://dev.risczero.com/api/zkvm/quickstart#2-create-a-new-project) you will have to stage the newly created files (as Nix will ignore files that are not captured by version control) and change the source directory: Assuming you've created a risc0 project called `my_project` in the root directory of your repository, change
```nix
packages.${system}.risc0package = risc0pkgs.lib.${system}.buildRisc0Package {
pname = "risc0package";
version = "0.0.1";
src = ./.;
doCheck = false;
cargoSha256 = pkgs.lib.fakeSha256;
};
```
to
```nix
packages.${system}.risc0package = risc0pkgs.lib.${system}.buildRisc0Package {
pname = "risc0package";
version = "0.0.1";
src = ./my_project;
doCheck = false;
cargoSha256 = pkgs.lib.fakeSha256;
};
```
## Development Shell

To get dropped into a development shell with all the required tooling, run:

Running `nix build .#risc0package` will error the first time you run it because we still have to change the `cargoSha256`. Nix will tell us after this first run what the expected hash should be. Copy the expected hash and paste it here `cargoSha256 = "<hash>";`.
```sh
nix develop
```
4 changes: 4 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,9 @@
nixpkgs-fmt --check .
touch $out
'';
templates.default = {
path = ./templates/default;
description = "risc0 project template";
};
};
}
Loading

0 comments on commit cee0b8b

Please sign in to comment.