feat(notstrap): add new-machine bootstrap orchestrator
This commit is contained in:
25
crates/notstrap/src/prereqs.rs
Normal file
25
crates/notstrap/src/prereqs.rs
Normal file
@@ -0,0 +1,25 @@
|
||||
use anyhow::Result;
|
||||
use which::which;
|
||||
|
||||
pub struct Prereq {
|
||||
pub cmd: &'static str,
|
||||
pub install_hint: &'static str,
|
||||
}
|
||||
|
||||
const PREREQS: &[Prereq] = &[
|
||||
Prereq { cmd: "nu", install_hint: "brew install nushell OR nix-env -iA nixpkgs.nushell" },
|
||||
Prereq { cmd: "sops", install_hint: "brew install sops OR nix-env -iA nixpkgs.sops" },
|
||||
Prereq { cmd: "age", install_hint: "brew install age OR nix-env -iA nixpkgs.age" },
|
||||
];
|
||||
|
||||
pub fn check_prerequisites() -> Result<()> {
|
||||
let missing: Vec<&Prereq> = PREREQS.iter().filter(|p| which(p.cmd).is_err()).collect();
|
||||
if missing.is_empty() {
|
||||
return Ok(());
|
||||
}
|
||||
eprintln!("Missing required tools:\n");
|
||||
for p in &missing {
|
||||
eprintln!(" {} — {}", p.cmd, p.install_hint);
|
||||
}
|
||||
anyhow::bail!("{} prerequisite(s) missing", missing.len())
|
||||
}
|
||||
Reference in New Issue
Block a user