Skip to content

Commit

Permalink
Holochain runtime WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
guillemcordoba committed May 16, 2024
1 parent 8140a55 commit e5aa2b4
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 12 deletions.
26 changes: 19 additions & 7 deletions crates/scaffold_holochain_runtime/src/bin/main.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
use anyhow::Result;
use anyhow::{anyhow, Result};
use build_fs_tree::{Build, MergeableFileSystemTree};
use clap::Parser;
use colored::Colorize;
use scaffold_holochain_runtime::scaffold_holochain_runtime;
use std::{
ffi::OsString,
fs,
path::PathBuf,
process::{Command, ExitCode},
};
Expand Down Expand Up @@ -32,21 +33,32 @@ fn main() -> ExitCode {
fn internal_main() -> Result<()> {
let args = Args::parse();

let file_tree = scaffold_holochain_runtime(args.name)?;
let (name, file_tree) = scaffold_holochain_runtime(args.name)?;

let runtime_path = args.path.join(&name);

if std::fs::canonicalize(&runtime_path)?.exists() {
return Err(anyhow!(
"The directory {runtime_path:?} already exists: choose another name"
));
}

fs::create_dir_all(&runtime_path)?;

let file_tree = MergeableFileSystemTree::<OsString, String>::from(file_tree);

file_tree.build(&args.path)?;
file_tree.build(&runtime_path)?;

println!(
"{}",
format!("Successfully scaffolded executable happ").green()
format!("Successfully scaffolded holochain runtime").green()
);

println!("Running nix flake update...");
Command::new("nix").args(["flake", "update"]).output()?;

// TODO: run {package_manager} install?
Command::new("nix")
.args(["flake", "update"])
.current_dir(runtime_path)
.output()?;

Ok(())
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
description = "Template for Holochain app development";

inputs = {
versions.url = "github:holochain/holochain?dir=versions/0_3_rc";

holochain.url = "github:holochain/holochain";
holochain.inputs.versions.follows = "versions";

nixpkgs.follows = "holochain/nixpkgs";
flake-parts.follows = "holochain/flake-parts";

tauri-plugin-holochain.url = "github:darksoil-studio/tauri-plugin-holochain";
};

outputs = inputs:
inputs.flake-parts.lib.mkFlake { inherit inputs; } {
systems = builtins.attrNames inputs.holochain.devShells;
perSystem = { inputs', config, pkgs, system, ... }: {
devShells.default = pkgs.mkShell {
inputsFrom = [ inputs'.tauriHolochain.devShells.holochainTauriDev ];
};
devShells.androidDev = pkgs.mkShell {
inputsFrom = [ inputs'.tauriHolochain.devShells.holochainTauriAndroidDev];
};
};
};
}
5 changes: 1 addition & 4 deletions crates/scaffold_tauri_app/src/bin/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,7 @@ fn internal_main() -> Result<()> {

file_tree.build(&args.path)?;

println!(
"{}",
format!("Successfully scaffolded executable happ").green()
);
println!("{}", format!("Successfully scaffolded tauri app").green());

println!("Running nix flake update...");
Command::new("nix").args(["flake", "update"]).output()?;
Expand Down
1 change: 0 additions & 1 deletion examples/tauri-app/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
inputs.flake-parts.lib.mkFlake { inherit inputs; } {
systems = builtins.attrNames inputs.holochain.devShells;
perSystem = { inputs', config, pkgs, system, ... }: {
# devShells.default = inputs'.tauriHolochain.devShells.holochainTauriDev;
devShells.default = pkgs.mkShell {
inputsFrom = [ inputs'.tauriHolochain.devShells.holochainTauriDev ];
};
Expand Down

0 comments on commit e5aa2b4

Please sign in to comment.