Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
marijanp committed Jan 9, 2024
0 parents commit 0812902
Show file tree
Hide file tree
Showing 18 changed files with 2,634 additions and 0 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: check
on:
pull_request:
branches: [main]
push:
branches: [main]

jobs:
checks:
name: format & build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: DeterminateSystems/nix-installer-action@main
- uses: DeterminateSystems/magic-nix-cache-action@v2

- name: System Info
run: |
uname -a
nix --version
- name: check
run: nix flake check -L --show-trace

- name: kairos-node
run: nix build -L --no-link --show-trace .#packages.x86_64-linux.kairos-node

- name: kairos-prover
run: nix build -L --no-link --show-trace .#packages.x86_64-linux.kairos-prover
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
result
.direnv
.envrc
target
.tmp
.nixos-test-history
183 changes: 183 additions & 0 deletions flake.lock

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

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

nixConfig = {
extra-substituters = [
"https://crane.cachix.org"
"https://nix-community.cachix.org"
];
extra-trusted-public-keys = [
"crane.cachix.org-1:8Scfpmn9w+hGdXH/Q9tTLiYAE/2dnJYRJP7kl80GuRk="
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
];
};

inputs = {
flake-parts.url = "github:hercules-ci/flake-parts";
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
treefmt-nix.url = "github:numtide/treefmt-nix";
treefmt-nix.inputs.nixpkgs.follows = "nixpkgs";
fenix.url = "github:nix-community/fenix";
fenix.inputs.nixpkgs.follows = "nixpkgs";
crane.url = "github:ipetkov/crane";
crane.inputs.nixpkgs.follows = "nixpkgs";
advisory-db.url = "github:rustsec/advisory-db";
advisory-db.flake = false;
risc0pkgs.url = "github:cspr-rad/risc0pkgs";
risc0pkgs.inputs.nixpkgs.follows = "nixpkgs";
};

outputs = inputs@{ self, flake-parts, treefmt-nix, ... }:
flake-parts.lib.mkFlake { inherit inputs; } {
systems = [ "x86_64-linux" ];
imports = [
treefmt-nix.flakeModule
./kairos-prover
];
perSystem = { config, self', inputs', system, pkgs, lib, ... }:
let
rustToolchain = inputs'.fenix.packages.complete.toolchain;
craneLib = inputs.crane.lib.${system}.overrideToolchain rustToolchain;

kairosNodeAttrs = {
src = lib.cleanSourceWith {
src = craneLib.path ./kairos-node;
filter = path: type: craneLib.filterCargoSources path type;
};
nativeBuildInputs = with pkgs; [ pkg-config openssl.dev ];
};
in
{
devShells.default = pkgs.mkShell {
# Rust Analyzer needs to be able to find the path to default crate
RUST_SRC_PATH = "${rustToolchain}/lib/rustlib/src/rust/library";

nativeBuildInputs = [
rustToolchain
] ++ kairosNodeAttrs.nativeBuildInputs;
};

packages = {
kairos-node-deps = craneLib.buildDepsOnly (kairosNodeAttrs // {
pname = "kairos-node";
});

kairos-node = craneLib.buildPackage (kairosNodeAttrs // {
cargoArtifacts = self'.packages.kairos-node-deps;
});

default = self'.packages.kairos-node;

kairos-node-docs = craneLib.cargoDoc (kairosNodeAttrs // {
cargoArtifacts = self'.packages.kairos-node-deps;
});
};

checks = {
lint = craneLib.cargoClippy (kairosNodeAttrs // {
cargoArtifacts = self'.packages.kairos-node-deps;
cargoClippyExtraArgs = "--all-targets -- --deny warnings";
});

coverage-report = craneLib.cargoTarpaulin (kairosNodeAttrs // {
cargoArtifacts = self'.packages.kairos-node-deps;
});

audit = craneLib.cargoAudit {
inherit (kairosNodeAttrs) src;
advisory-db = inputs.advisory-db;
};
};

treefmt = {
projectRootFile = ".git/config";
programs.nixpkgs-fmt.enable = true;
programs.rustfmt.enable = true;
programs.rustfmt.package = craneLib.rustfmt;
settings.formatter = { };
};
};
};
}
7 changes: 7 additions & 0 deletions kairos-node/Cargo.lock

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

8 changes: 8 additions & 0 deletions kairos-node/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[package]
name = "kairos-node"
version = "0.1.0"
edition = "2021"

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

[dependencies]
3 changes: 3 additions & 0 deletions kairos-node/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fn main() {
println!("Hello, world!");
}
Loading

0 comments on commit 0812902

Please sign in to comment.