Skip to content

Commit

Permalink
Merge pull request #182 from cspr-rad/minor-refactorings
Browse files Browse the repository at this point in the history
Minor refactorings
  • Loading branch information
marijanp authored Aug 24, 2024
2 parents 4aa7429 + abdfb6e commit 53c6f5f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6,750 deletions.
15 changes: 9 additions & 6 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@
csprpkgs.url = "github:cspr-rad/csprpkgs";
};

outputs = inputs@{ self, flake-parts, treefmt-nix, ... }:
outputs = inputs@{ flake-parts, treefmt-nix, ... }:
flake-parts.lib.mkFlake { inherit inputs; } {
systems = [ "x86_64-linux" "x86_64-darwin" "aarch64-darwin" ];
imports = [
treefmt-nix.flakeModule
./kairos-prover
./nixos
];
perSystem = { config, self', inputs', system, pkgs, lib, ... }:
perSystem = { self', inputs', system, pkgs, lib, ... }:
let
rustToolchain = with inputs'.fenix.packages; combine [
stable.toolchain
Expand Down Expand Up @@ -193,10 +193,11 @@

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

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

Expand Down Expand Up @@ -227,20 +228,22 @@
cargoArtifacts = self'.packages.kairos-deps;
});

kairos-contracts-deps = craneLib.buildPackage (kairosContractsAttrs // {
pname = "kairos-contracts";
kairos-contracts-deps = craneLib.buildDepsOnly (kairosContractsAttrs // {
pname = "kairos-contracts-deps";
});

kairos-contracts = craneLib.buildPackage (kairosContractsAttrs // {
pname = "kairos-contracts";
cargoArtifacts = self'.packages.kairos-contracts-deps;
});

kairos-session-code-deps = craneLib.buildPackage (kairosSessionCodeAttrs // {
kairos-session-code-deps = craneLib.buildDepsOnly (kairosSessionCodeAttrs // {
pname = "kairos-session-code-deps";
});

kairos-session-code = craneLib.buildPackage (kairosSessionCodeAttrs // {
pname = "kairos-session-code";
cargoArtifacts = self'.packages.kairos-session-code-deps;
});

casper-chainspec = pkgs.fetchurl {
Expand Down
22 changes: 4 additions & 18 deletions kairos-prover/default.nix
Original file line number Diff line number Diff line change
@@ -1,25 +1,10 @@
{ self, inputs, ... }:
{ inputs, ... }:
{
perSystem = { self', inputs', system, pkgs, lib, ... }:
let
rustToolchain = inputs'.fenix.packages.latest.toolchain;
craneLib = inputs.crane.lib.${system}.overrideToolchain rustToolchain;

rustup-mock = pkgs.writeShellApplication {
name = "rustup";
text = ''
# the buildscript uses rustup toolchain to check
# whether the risc0 toolchain was installed
if [[ "$1" = "toolchain" ]]
then
printf "risc0\n"
elif [[ "$1" = "+risc0" ]]
then
printf "${rustToolchain}/bin/rustc"
fi
'';
};

kairosProverAttrs = rec {
src = lib.fileset.toSource {
root = ../.;
Expand Down Expand Up @@ -78,14 +63,15 @@
RISC0_RUST_SRC = "${rustToolchain}/lib/rustlib/src/rust";
RISC0_DEV_MODE = 0;
RISC0_R0VM_PATH = lib.getExe pkgs.r0vm;
inputsFrom = [ self.packages.${system}.kairos-prover ];
inputsFrom = [ self'.packages.kairos-prover ];
};
packages = {
kairos-prover-deps = craneLib.buildDepsOnly (kairosProverAttrs // {
pname = "kairos";
pname = "kairos-prover-deps";
});

kairos-prover = craneLib.buildPackage (kairosProverAttrs // {
pname = "kairos-prover";
cargoArtifacts = self'.packages.kairos-prover-deps;
meta.mainProgram = "kairos-prover-risc0-server";
});
Expand Down
Loading

0 comments on commit 53c6f5f

Please sign in to comment.