Set up initial structure for the nix builder.

This commit is contained in:
Tom Alexander
2026-02-14 13:31:21 -05:00
commit 9344e5708f
19 changed files with 2267 additions and 0 deletions

3
src/command/build/mod.rs Normal file
View File

@@ -0,0 +1,3 @@
mod runner;
pub(crate) use runner::run_build;

View File

@@ -0,0 +1,29 @@
use crate::cli::parameters::BuildArgs;
use crate::config::Config;
use crate::config::TargetConfig;
use crate::error::CustomError;
pub(crate) async fn run_build(args: BuildArgs) -> Result<(), CustomError> {
println!("{:?}", args);
let config = Config::load_from_file(args.config).await?;
println!("{:?}", config);
for target_name in args.target {
let target_config = {
let target_config = config.get_target_config(&target_name)?;
if let Some(conf) = target_config {
conf
} else {
return Err(format!("Could not find target {}", target_name).into());
}
};
prepare_flake_repo(target_config).await?;
}
Ok(())
}
async fn prepare_flake_repo(target_config: &TargetConfig) -> Result<(), CustomError> {
todo!()
}

View File

@@ -0,0 +1,3 @@
mod runner;
pub(crate) use runner::start_daemon;

View File

@@ -0,0 +1,23 @@
use crate::cli::parameters::DaemonArgs;
use crate::config::Config;
use crate::error::CustomError;
pub(crate) async fn start_daemon(args: DaemonArgs) -> Result<(), CustomError> {
if args.path.exists() && !args.path.is_dir() {
return Err("The supplied path exists but is not a directory. Aborting.".into());
}
if !args.path.exists() {
tokio::fs::create_dir_all(&args.path).await?;
}
let mut existing_entries = tokio::fs::read_dir(&args.path).await?;
let first_entry = existing_entries.next_entry().await?;
if first_entry.is_some() {
return Err("The directory is not empty. Aborting.".into());
}
let new_config = Config::new(args.path)?;
new_config.write_to_disk().await?;
Ok(())
}

2
src/command/mod.rs Normal file
View File

@@ -0,0 +1,2 @@
pub(crate) mod build;
pub(crate) mod daemon;