git.delta.rocks / jrsonnet / refs/commits / 13f8ec8b964e

difftreelog

fix secret generation

Yaroslav Bolyukin2024-09-09parent: #ef18a9f.patch.diff
in: trunk

3 files changed

modifiedcrates/fleet-base/src/host.rsdiffbeforeafterboth
--- a/crates/fleet-base/src/host.rs
+++ b/crates/fleet-base/src/host.rs
@@ -61,6 +61,7 @@
 
 	pub host_config: Option<Value>,
 	pub nixos_config: OnceCell<Value>,
+	pub pkgs_override: Option<Value>,
 
 	// TODO: Move command helpers away with connectivity refactor
 	pub local: bool,
@@ -297,6 +298,9 @@
 
 	/// Packages for this host, resolved with nixpkgs overlays
 	pub async fn pkgs(&self) -> Result<Value> {
+		if let Some(value) = &self.pkgs_override {
+			return Ok(value.clone());
+		}
 		let Some(host_config) = &self.host_config else {
 			bail!("local host has no host_config");
 		};
@@ -310,8 +314,6 @@
 		ConfigHost {
 			config: self.clone(),
 			name: "<virtual localhost>".to_owned(),
-			local: true,
-			session: OnceLock::new(),
 			host_config: None,
 			nixos_config: OnceCell::new(),
 			groups: {
@@ -319,6 +321,10 @@
 				let _ = cell.set(vec![]);
 				cell
 			},
+			pkgs_override: Some(self.default_pkgs.clone()),
+
+			local: true,
+			session: OnceLock::new(),
 		}
 	}
 
@@ -332,7 +338,8 @@
 			host_config: Some(host_config),
 			nixos_config: OnceCell::new(),
 			groups: OnceCell::new(),
-			
+			pkgs_override: None,
+
 			// TODO: Remove with connectivit refactor
 			local: self.localhost == name,
 			session: OnceLock::new(),
modifiedcrates/fleet-base/src/opts.rsdiffbeforeafterboth
--- a/crates/fleet-base/src/opts.rs
+++ b/crates/fleet-base/src/opts.rs
@@ -196,11 +196,11 @@
 
 		let import = nix_go!(builtins_field.import);
 		let overlays = nix_go!(config_field.nixpkgs.overlays);
-		let nixpkgs = nix_go!(fleet_field.nixpkgs.buildUsing | import);
+		let nixpkgs = nix_go!(config_field.nixpkgs.buildUsing | import);
 
 		let default_pkgs = nix_go!(nixpkgs(Obj {
 			overlays,
-			system: { self.local_system.clone() },
+			system: { local_system.clone() },
 		}));
 
 		Ok(Config(Arc::new(FleetConfigInternals {
modifiedlib/flakePart.nixdiffbeforeafterboth
before · lib/flakePart.nix
1{crane}: {2  fleetLib,3  lib,4  config,5  inputs ? {},6  ...7}: let8  inherit (lib.options) mkOption;9  inherit (lib.attrsets) mapAttrs;10  inherit (lib.types) lazyAttrsOf deferredModule unspecified;11  inherit (lib.strings) isPath;12  inherit (fleetLib.options) mkHostsOption;13in {14  options.fleetModules = mkOption {15    type = lazyAttrsOf unspecified;16    default = {};17  };18  options.fleetConfigurations = mkOption {19    type = lazyAttrsOf deferredModule;20    apply = nameToModule:21      mapAttrs (22        name: module: data: let23          # To use user-provided nixpkgs, we first need to extract wanted nixpkgs attribute,24          # to do that, evaluate all the modules with only needed option declared.25          bootstrapEval = lib.evalModules {26            modules = [27              module28              {29                options.nixpkgs.buildUsing = mkOption {30                  description = ''31                    Nixpkgs to use for fleetConfiguration evaluation.32                  '';33                };34                config._module.check = false;35              }36            ];37          };38          bootstrapNixpkgs = bootstrapEval.config.nixpkgs.buildUsing;39          normalEval = bootstrapNixpkgs.lib.evalModules {40            modules =41              (import ../modules/module-list.nix)42              ++ [43                module44                {45                  options.hosts = mkHostsOption {46                    nixos.nixpkgs.overlays = [47                      (final: prev:48                        import ../pkgs {49                          inherit (prev) callPackage;50                          craneLib = crane.mkLib prev;51                        })52                    ];53                  };54                  config = {55                    data =56                      if isPath data57                      then import data58                      else data;59                  };60                }61              ];62            specialArgs = {63              inherit inputs;64              fleetLib = import ../lib {65                inherit (bootstrapNixpkgs) lib;66              };67            };68          };69        in70          normalEval71      )72      nameToModule;73  };74  config = {75    _module.args.fleetLib = import ../lib {inherit lib;};76    flake.fleetConfigurations = config.fleetConfigurations;77    flake.fleetModules = config.fleetModules;78  };7980  _file = ./flakePart.nix;81}
after · lib/flakePart.nix
1{crane}: {2  fleetLib,3  lib,4  config,5  inputs ? {},6  ...7}: let8  inherit (lib.options) mkOption;9  inherit (lib.attrsets) mapAttrs;10  inherit (lib.types) lazyAttrsOf deferredModule unspecified;11  inherit (lib.strings) isPath;12in {13  options.fleetModules = mkOption {14    type = lazyAttrsOf unspecified;15    default = {};16  };17  options.fleetConfigurations = mkOption {18    type = lazyAttrsOf deferredModule;19    apply = nameToModule:20      mapAttrs (21        name: module: data: let22          # To use user-provided nixpkgs, we first need to extract wanted nixpkgs attribute,23          # to do that, evaluate all the modules with only needed option declared.24          bootstrapEval = lib.evalModules {25            modules = [26              module27              {28                options.nixpkgs.buildUsing = mkOption {29                  description = ''30                    Nixpkgs to use for fleetConfiguration evaluation.31                  '';32                };33                config._module.check = false;34              }35            ];36          };37          bootstrapNixpkgs = bootstrapEval.config.nixpkgs.buildUsing;38          normalEval = bootstrapNixpkgs.lib.evalModules {39            modules =40              (import ../modules/module-list.nix)41              ++ [42                module43                {44                  config = {45                    data =46                      if isPath data47                      then import data48                      else data;49                    nixpkgs.overlays = [50                      (final: prev:51                        import ../pkgs {52                          inherit (prev) callPackage;53                          craneLib = crane.mkLib prev;54                        })55                    ];56                  };57                }58              ];59            specialArgs = {60              inherit inputs;61              fleetLib = import ../lib {62                inherit (bootstrapNixpkgs) lib;63              };64            };65          };66        in67          normalEval68      )69      nameToModule;70  };71  config = {72    _module.args.fleetLib = import ../lib {inherit lib;};73    flake.fleetConfigurations = config.fleetConfigurations;74    flake.fleetModules = config.fleetModules;75  };7677  _file = ./flakePart.nix;78}