feat: minimal systemd support
This commit is contained in:
parent
3052ba7b25
commit
09fb938cb4
|
@ -10,18 +10,25 @@ use std::{
|
|||
process::{Command, Output, Stdio},
|
||||
};
|
||||
|
||||
fn gen_systems_path(system: &str) -> String {
|
||||
fn gen_systems_path(system: &str, minimal: bool) -> String {
|
||||
if minimal {
|
||||
format!(
|
||||
".#minimalConfigurations.{}.config.system.build.toplevel",
|
||||
system
|
||||
)
|
||||
} else {
|
||||
format!(
|
||||
".#nixosConfigurations.{}.config.system.build.toplevel",
|
||||
system
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn build(systems: &[String], show_trace: bool) -> Result<Output> {
|
||||
pub fn build(systems: &[String], show_trace: bool, minimal: bool) -> Result<Output> {
|
||||
let dir = env::var("PRJ_ROOT")
|
||||
.map(PathBuf::from)
|
||||
.or_else(|_| env::current_dir())?;
|
||||
let configs = systems.iter().map(|x| gen_systems_path(x));
|
||||
let configs = systems.iter().map(|x| gen_systems_path(x, minimal));
|
||||
let mut cmd = Command::new("nom");
|
||||
let mut cmd = if cmd
|
||||
.arg("--version")
|
||||
|
@ -51,7 +58,7 @@ pub fn build(systems: &[String], show_trace: bool) -> Result<Output> {
|
|||
cmd.output().wrap_err("Error building systems")
|
||||
}
|
||||
|
||||
pub async fn deploy(systems: &[String], show_trace: bool, mode: &str) -> Result<()> {
|
||||
pub async fn deploy(systems: &[String], mode: &str, show_trace: bool, minimal: bool) -> Result<()> {
|
||||
let (systems, hosts): (Vec<_>, Vec<_>) = systems
|
||||
.iter()
|
||||
.map(|x| x.split_once('@').unwrap_or((x, x)))
|
||||
|
@ -69,6 +76,7 @@ pub async fn deploy(systems: &[String], show_trace: bool, mode: &str) -> Result<
|
|||
build(
|
||||
&systems.iter().map(|x| x.to_string()).collect::<Vec<_>>(),
|
||||
show_trace,
|
||||
minimal,
|
||||
)?
|
||||
.stdout,
|
||||
)?;
|
||||
|
@ -85,6 +93,7 @@ pub async fn deploy(systems: &[String], show_trace: bool, mode: &str) -> Result<
|
|||
)
|
||||
.arg("copy")
|
||||
.arg("--substitute-on-destination")
|
||||
// Could add a --no-check-sigs option here to enable people who don't sign their stores
|
||||
.arg("--to")
|
||||
.arg(format!("ssh-ng://root@{}?compress=true", host))
|
||||
.arg(toplevel);
|
||||
|
|
|
@ -57,6 +57,9 @@ struct Deploy {
|
|||
show_trace: bool,
|
||||
#[arg(long, default_value_t = ("switch".to_string()))]
|
||||
mode: String,
|
||||
/// This deploys a minimal configation, expected under flake output minimalConfigurations
|
||||
#[arg(long, default_value_t = false)]
|
||||
minimal: bool,
|
||||
}
|
||||
|
||||
#[derive(Args, Debug, Default)]
|
||||
|
@ -142,7 +145,7 @@ async fn main() -> Result<()> {
|
|||
)
|
||||
.exit()
|
||||
}
|
||||
build(&opts.systems, opts.show_trace)?;
|
||||
build(&opts.systems, opts.show_trace, opts.minimal)?;
|
||||
}
|
||||
|
||||
CliCommands::Deploy(opts) => {
|
||||
|
@ -154,7 +157,7 @@ async fn main() -> Result<()> {
|
|||
)
|
||||
.exit()
|
||||
}
|
||||
deploy(&opts.systems, opts.show_trace, &opts.mode).await?;
|
||||
deploy(&opts.systems, &opts.mode, opts.show_trace, opts.minimal).await?;
|
||||
}
|
||||
};
|
||||
Ok(())
|
||||
|
|
Loading…
Reference in a new issue