Add ability to build nix derivations

Signed-off-by: Marcel Müller <neikos@neikos.email>
This commit is contained in:
Marcel Müller 2026-01-11 11:43:24 +01:00
parent 85c6a8f169
commit 8005aeccd9
8 changed files with 296 additions and 97 deletions

53
nixie-cli/src/main.rs Normal file
View file

@ -0,0 +1,53 @@
use clap::Parser;
use clap::Subcommand;
use nixie_build::NixBackend;
use nixie_build::NixBuilder;
use nixie_build::NixCliBackend;
#[derive(Debug, Parser)]
#[command(version, about)]
struct Args {
#[clap(subcommand)]
command: ArgCommand,
}
#[derive(Debug, Subcommand)]
enum ArgCommand {
Build { installable: String },
}
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let args = Args::parse();
run(args).await
}
async fn run(args: Args) -> anyhow::Result<()> {
match args.command {
ArgCommand::Build { installable } => {
build_and_report(NixCliBackend::new("nix".to_string()), installable).await?;
}
}
Ok(())
}
async fn build_and_report<B: NixBackend>(backend: B, installable: String) -> anyhow::Result<()> {
let builder = NixBuilder::new(backend);
let build_result = builder.build(installable).await?;
for (drv, result) in build_result {
println!(
"Built:\t{drv}: {}",
if result.success() {
"Succesfully"
} else {
"Errored"
}
)
}
Ok(())
}