--- a/crates/fleet-base/src/opts.rs +++ b/crates/fleet-base/src/opts.rs @@ -87,6 +87,13 @@ /// binfmt-declared qemu instead of trying to crosscompile #[clap(long, default_value = env!("NIX_SYSTEM"))] pub local_system: String, + + /// By default fleet continues on single derivation build failure + /// this flag makes command fail immediately + /// + /// Opposite of Nix's --keep-going + #[clap(long)] + pub fail_fast: bool, } impl FleetOpts { @@ -204,6 +211,7 @@ directory.as_os_str().to_owned(), nix_args.clone(), self.local_system.clone(), + self.fail_fast, ) .await?; let nix_session = pool.get().await?; --- a/crates/nix-eval/src/pool.rs +++ b/crates/nix-eval/src/pool.rs @@ -9,7 +9,12 @@ pub struct NixSessionPool(Pool); impl NixSessionPool { - pub async fn new(flake: OsString, nix_args: Vec, nix_system: String) -> Result { + pub async fn new( + flake: OsString, + nix_args: Vec, + nix_system: String, + fail_fast: bool, + ) -> Result { let inner = tokio::task::block_in_place(|| { r2d2::Builder::::new() .min_idle(Some(0)) @@ -17,6 +22,7 @@ flake, nix_args, nix_system, + fail_fast, }) })?; Ok(Self(inner)) @@ -30,6 +36,7 @@ pub(crate) struct NixSessionPoolInner { flake: OsString, nix_args: Vec, + fail_fast: bool, pub(crate) nix_system: String, } @@ -41,11 +48,12 @@ .get() .expect("missed tokio runtime init!") .enter(); - Ok(futures::executor::block_on(NixSessionInner::new( + futures::executor::block_on(NixSessionInner::new( self.flake.as_os_str(), self.nix_args.iter().map(OsString::as_os_str), self.nix_system.clone(), - ))?) + self.fail_fast, + )) } fn is_valid(&self, conn: &mut Self::Connection) -> std::result::Result<(), Self::Error> { --- a/crates/nix-eval/src/session.rs +++ b/crates/nix-eval/src/session.rs @@ -225,6 +225,7 @@ flake: &OsStr, extra_args: impl IntoIterator, nix_system: String, + fail_fast: bool, ) -> Result { let mut cmd = Command::new("nix"); cmd.arg("repl") @@ -232,6 +233,9 @@ .arg(flake) .arg("--log-format") .arg("internal-json"); + if !fail_fast { + cmd.arg("--keep-going"); + } for arg in extra_args { cmd.arg(arg); } --- a/flake.nix +++ b/flake.nix @@ -136,7 +136,7 @@ inherit (packages) fleet-install-secrets; }) // { - checks.formatting = treefmt.check self; + formatting = treefmt.check self; }; # TODO: It should be possible to move lib.mkIf to default attribute, instead of disabling the whole # devShells block, yet nix flake check fails here, due to no default shell found. It is nix or flake-parts bug?