git.delta.rocks / jrsonnet / refs/commits / f39d78019a7e

difftreelog

feat adopt keep-going-by-default behavior

Lach2025-05-12parent: #03574ae.patch.diff
in: trunk

4 files changed

modifiedcrates/fleet-base/src/opts.rsdiffbeforeafterboth
--- 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?;
modifiedcrates/nix-eval/src/pool.rsdiffbeforeafterboth
--- a/crates/nix-eval/src/pool.rs
+++ b/crates/nix-eval/src/pool.rs
@@ -9,7 +9,12 @@
 
 pub struct NixSessionPool(Pool<NixSessionPoolInner>);
 impl NixSessionPool {
-	pub async fn new(flake: OsString, nix_args: Vec<OsString>, nix_system: String) -> Result<Self> {
+	pub async fn new(
+		flake: OsString,
+		nix_args: Vec<OsString>,
+		nix_system: String,
+		fail_fast: bool,
+	) -> Result<Self> {
 		let inner = tokio::task::block_in_place(|| {
 			r2d2::Builder::<NixSessionPoolInner>::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<OsString>,
+	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> {
modifiedcrates/nix-eval/src/session.rsdiffbeforeafterboth
--- a/crates/nix-eval/src/session.rs
+++ b/crates/nix-eval/src/session.rs
@@ -225,6 +225,7 @@
 		flake: &OsStr,
 		extra_args: impl IntoIterator<Item = &OsStr>,
 		nix_system: String,
+		fail_fast: bool,
 	) -> Result<Self> {
 		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);
 		}
modifiedflake.nixdiffbeforeafterboth
before · flake.nix
1{2  description = "NixOS cluster configuration management";34  inputs = {5    nixpkgs.url = "github:nixos/nixpkgs/release-24.11";6    rust-overlay = {7      url = "github:oxalica/rust-overlay";8      inputs.nixpkgs.follows = "nixpkgs";9    };10    flake-parts = {11      url = "github:hercules-ci/flake-parts";12      inputs.nixpkgs-lib.follows = "nixpkgs";13    };14    crane.url = "github:ipetkov/crane";15    shelly.url = "github:CertainLach/shelly";16    treefmt-nix = {17      url = "github:numtide/treefmt-nix";18      inputs.nixpkgs.follows = "nixpkgs";19    };20  };21  outputs =22    inputs:23    inputs.flake-parts.lib.mkFlake24      {25        inherit inputs;26      }27      {28        imports = [ inputs.shelly.flakeModule ];29        flake = rec {30          lib =31            (import ./lib {32              inherit (inputs.nixpkgs) lib;33            })34            // {35              fleetConfiguration = throw "function-based interface is deprecated, use flake-parts syntax instead";36            };37          flakeModules.default = import ./lib/flakePart.nix {38            inherit (inputs) crane;39          };40          flakeModule = flakeModules.default;4142          fleetModules.tf = ./modules/extras/tf.nix;4344          # To be used with https://github.com/NixOS/nix/pull/889245          schemas =46            let47              inherit (inputs.nixpkgs.lib) mapAttrs;48            in49            {50              fleetConfigurations = {51                version = 1;52                doc = ''53                  The `fleetConfigurations` flake output defines fleet cluster configurations.54                '';55                inventory = output: {56                  children = mapAttrs (configName: cluster: {57                    what = "fleet cluster configuration";5859                    children = mapAttrs (hostName: host: {60                      what = "host [${host.system}]";61                    }) cluster.config.hosts;62                    # It is possible to implement this inventory right now, but I want to63                    # get rid of `fleet.nix` file in the future.64                    # children.secrets = { };65                  }) output;66                };67              };68            };69        };70        # Supported and tested list of deployment targets.71        systems = [72          "x86_64-linux"73          "aarch64-linux"74          "armv7l-linux"75          "armv6l-linux"76        ];77        perSystem =78          {79            config,80            system,81            pkgs,82            self,83            ...84          }:85          let86            inherit (lib.attrsets) mapAttrs';87            inherit (lib.lists) elem;88            # Can also be built for darwin, through it is not usual to deploy nixos systems from macos machines.89            # I have no hardware for such testing, thus only adding machines I actually have and use.90            #91            # It is not possible to deploy any host from armv6/armv7 hardware, and I don't think it even makes sense.92            deployerSystems = [93              "aarch64-linux"94              "x86_64-linux"95            ];96            deployerSystem = elem system deployerSystems;97            lib = pkgs.lib;98            rust = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;99            craneLib = (inputs.crane.mkLib pkgs).overrideToolchain rust;100            treefmt = (inputs.treefmt-nix.lib.evalModule pkgs ./treefmt.nix).config.build;101          in102          {103            _module.args.pkgs = import inputs.nixpkgs {104              inherit system;105              overlays = [ (inputs.rust-overlay.overlays.default) ];106            };107            # Reference fleet package should be built with nightly rust, specified in rust-toolchain.toml.108            packages = lib.mkIf deployerSystem (109              let110                packages = pkgs.callPackages ./pkgs {111                  inherit craneLib;112                };113              in114              packages // { default = packages.fleet; }115            );116            # fleet-install-secrets will not be built normally, because they are not ran directly by user most of the time.117            # checks there build packages for default nixpkgs rustPlatform packages.118            checks =119              let120                nixpkgsCraneLib = inputs.crane.mkLib pkgs;121                packages = pkgs.callPackages ./pkgs {122                  craneLib = nixpkgsCraneLib;123                };124                prefixAttrs =125                  prefix: attrs:126                  mapAttrs' (name: value: {127                    name = "${prefix}${name}";128                    value = value.overrideAttrs (prev: {129                      pname = "${prefix}${prev.pname}";130                    });131                  }) attrs;132              in133              # fleet-install-secrets is installed to remote systems, thus needs to work134              # with rust in nixpkgs.135              (prefixAttrs "nixpkgs-" {136                inherit (packages) fleet-install-secrets;137              })138              // {139                checks.formatting = treefmt.check self;140              };141            # TODO: It should be possible to move lib.mkIf to default attribute, instead of disabling the whole142            # devShells block, yet nix flake check fails here, due to no default shell found. It is nix or flake-parts bug?143            shelly.shells.default = lib.mkIf deployerSystem {144              factory = craneLib.devShell;145              packages = with pkgs; [146                rust147                alejandra148                cargo-edit149                cargo-udeps150                cargo-fuzz151                cargo-watch152                cargo-outdated153154                pkg-config155                openssl156                bacon157                nil158                rustPlatform.bindgenHook159                nixVersions.nix_2_22160              ];161              environment.PROTOC = "${pkgs.protobuf}/bin/protoc";162            };163            formatter = treefmt.wrapper;164          };165      };166}
after · flake.nix
1{2  description = "NixOS cluster configuration management";34  inputs = {5    nixpkgs.url = "github:nixos/nixpkgs/release-24.11";6    rust-overlay = {7      url = "github:oxalica/rust-overlay";8      inputs.nixpkgs.follows = "nixpkgs";9    };10    flake-parts = {11      url = "github:hercules-ci/flake-parts";12      inputs.nixpkgs-lib.follows = "nixpkgs";13    };14    crane.url = "github:ipetkov/crane";15    shelly.url = "github:CertainLach/shelly";16    treefmt-nix = {17      url = "github:numtide/treefmt-nix";18      inputs.nixpkgs.follows = "nixpkgs";19    };20  };21  outputs =22    inputs:23    inputs.flake-parts.lib.mkFlake24      {25        inherit inputs;26      }27      {28        imports = [ inputs.shelly.flakeModule ];29        flake = rec {30          lib =31            (import ./lib {32              inherit (inputs.nixpkgs) lib;33            })34            // {35              fleetConfiguration = throw "function-based interface is deprecated, use flake-parts syntax instead";36            };37          flakeModules.default = import ./lib/flakePart.nix {38            inherit (inputs) crane;39          };40          flakeModule = flakeModules.default;4142          fleetModules.tf = ./modules/extras/tf.nix;4344          # To be used with https://github.com/NixOS/nix/pull/889245          schemas =46            let47              inherit (inputs.nixpkgs.lib) mapAttrs;48            in49            {50              fleetConfigurations = {51                version = 1;52                doc = ''53                  The `fleetConfigurations` flake output defines fleet cluster configurations.54                '';55                inventory = output: {56                  children = mapAttrs (configName: cluster: {57                    what = "fleet cluster configuration";5859                    children = mapAttrs (hostName: host: {60                      what = "host [${host.system}]";61                    }) cluster.config.hosts;62                    # It is possible to implement this inventory right now, but I want to63                    # get rid of `fleet.nix` file in the future.64                    # children.secrets = { };65                  }) output;66                };67              };68            };69        };70        # Supported and tested list of deployment targets.71        systems = [72          "x86_64-linux"73          "aarch64-linux"74          "armv7l-linux"75          "armv6l-linux"76        ];77        perSystem =78          {79            config,80            system,81            pkgs,82            self,83            ...84          }:85          let86            inherit (lib.attrsets) mapAttrs';87            inherit (lib.lists) elem;88            # Can also be built for darwin, through it is not usual to deploy nixos systems from macos machines.89            # I have no hardware for such testing, thus only adding machines I actually have and use.90            #91            # It is not possible to deploy any host from armv6/armv7 hardware, and I don't think it even makes sense.92            deployerSystems = [93              "aarch64-linux"94              "x86_64-linux"95            ];96            deployerSystem = elem system deployerSystems;97            lib = pkgs.lib;98            rust = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;99            craneLib = (inputs.crane.mkLib pkgs).overrideToolchain rust;100            treefmt = (inputs.treefmt-nix.lib.evalModule pkgs ./treefmt.nix).config.build;101          in102          {103            _module.args.pkgs = import inputs.nixpkgs {104              inherit system;105              overlays = [ (inputs.rust-overlay.overlays.default) ];106            };107            # Reference fleet package should be built with nightly rust, specified in rust-toolchain.toml.108            packages = lib.mkIf deployerSystem (109              let110                packages = pkgs.callPackages ./pkgs {111                  inherit craneLib;112                };113              in114              packages // { default = packages.fleet; }115            );116            # fleet-install-secrets will not be built normally, because they are not ran directly by user most of the time.117            # checks there build packages for default nixpkgs rustPlatform packages.118            checks =119              let120                nixpkgsCraneLib = inputs.crane.mkLib pkgs;121                packages = pkgs.callPackages ./pkgs {122                  craneLib = nixpkgsCraneLib;123                };124                prefixAttrs =125                  prefix: attrs:126                  mapAttrs' (name: value: {127                    name = "${prefix}${name}";128                    value = value.overrideAttrs (prev: {129                      pname = "${prefix}${prev.pname}";130                    });131                  }) attrs;132              in133              # fleet-install-secrets is installed to remote systems, thus needs to work134              # with rust in nixpkgs.135              (prefixAttrs "nixpkgs-" {136                inherit (packages) fleet-install-secrets;137              })138              // {139                formatting = treefmt.check self;140              };141            # TODO: It should be possible to move lib.mkIf to default attribute, instead of disabling the whole142            # devShells block, yet nix flake check fails here, due to no default shell found. It is nix or flake-parts bug?143            shelly.shells.default = lib.mkIf deployerSystem {144              factory = craneLib.devShell;145              packages = with pkgs; [146                rust147                alejandra148                cargo-edit149                cargo-udeps150                cargo-fuzz151                cargo-watch152                cargo-outdated153154                pkg-config155                openssl156                bacon157                nil158                rustPlatform.bindgenHook159                nixVersions.nix_2_22160              ];161              environment.PROTOC = "${pkgs.protobuf}/bin/protoc";162            };163            formatter = treefmt.wrapper;164          };165      };166}