From 1d31a621fa6f50a7bd48d85cbd64b53249cf4aaa Mon Sep 17 00:00:00 2001 From: Yaroslav Bolyukin Date: Wed, 02 Dec 2020 14:38:57 +0000 Subject: [PATCH] feat(build-systems): builders/jobs/fail_fast args --- --- a/src/cmds/build_systems.rs +++ b/src/cmds/build_systems.rs @@ -17,6 +17,15 @@ /// Host, which should be threaten as localhost #[clap(long, env = "FLEET_LOCALHOST")] localhost: Option, + /// --builders arg for nix + #[clap(long)] + builders: Option, + /// Jobs to run locally + #[clap(long)] + jobs: Option, + /// Do not continue on error + #[clap(long)] + fail_fast: bool, #[clap(subcommand)] subcommand: Option, } @@ -61,16 +70,29 @@ dir.path().to_owned() }; - Command::new("nix") + let mut nix_build = Command::new("nix"); + nix_build .args(&["build", "--impure", "--no-link", "--out-link"]) .arg(&built) .arg(format!( "{}.{}.config.system.build.toplevel", SYSTEMS_ATTRIBUTE, host, )) - .env("SECRET_DATA", data.clone()) - .inherit_stdio() - .run()?; + .env("SECRET_DATA", data.clone()); + + if let Some(builders) = &self.builders { + println!("Using builders: {}", builders); + nix_build.arg("--builders").arg(builders); + } + if let Some(jobs) = &self.jobs { + nix_build.arg("--jobs"); + nix_build.arg(format!("{}", jobs)); + } + if !self.fail_fast { + nix_build.arg("--keep-going"); + } + + nix_build.inherit_stdio().run()?; let built = std::fs::canonicalize(built)?; info!("Built closure: {:?}", built); if !is_local { @@ -86,11 +108,11 @@ if subcommand.should_switch_profile() { info!("Switching generation"); if !is_local { - Command::ssh_on(host, "nix-env") + Command::ssh_on(host, "sudo") } else { - Command::new("nix-env") + Command::new("sudo") } - .args(&["-p", "/nix/var/nix/profiles/system", "--set"]) + .args(&["nix-env", "-p", "/nix/var/nix/profiles/system", "--set"]) .arg(&built) .inherit_stdio() .run()?; -- gitstuff