Add ability to build nix derivations
Signed-off-by: Marcel Müller <neikos@neikos.email>
This commit is contained in:
parent
85c6a8f169
commit
8005aeccd9
8 changed files with 296 additions and 97 deletions
13
nixie-cli/Cargo.toml
Normal file
13
nixie-cli/Cargo.toml
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
[package]
|
||||
name = "nixie-cli"
|
||||
edition.workspace = true
|
||||
version.workspace = true
|
||||
license.workspace = true
|
||||
authors.workspace = true
|
||||
readme.workspace = true
|
||||
|
||||
[dependencies]
|
||||
clap = { workspace = true, features = ["derive"] }
|
||||
anyhow = { workspace = true }
|
||||
tokio = { workspace = true, features = ["full"] }
|
||||
nixie-build.workspace = true
|
||||
53
nixie-cli/src/main.rs
Normal file
53
nixie-cli/src/main.rs
Normal 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(())
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue