{ hosts, lib, root, util, }: let definitions = lib.genAttrs' (util.collectNixFiles root) ( path: lib.nameValuePair (util.removeNixSuffix path) (mkRegistry path) ); # NOLINT(single_use_binding) mkRegistry = path: (lib.evalModules { specialArgs = { inherit util; }; modules = [ (import ./registry/schema.nix { inherit lib; }) path ]; }).config; data = validate ( lib.mapAttrs ( registryName: _registry: lib.mapAttrs (hostName: host: host.config.registry.${registryName}.${hostName} or { }) hosts ) definitions ); validate = import ./registry/validation.nix { inherit definitions lib; }; in { types = lib.mapAttrs (_name: definition: definition.type) definitions; module = { options.registry = lib.mapAttrs ( _name: registry: lib.mkOption { type = lib.types.attrsOf (lib.types.attrsOf registry.type); default = { }; description = '' Stores registry entries that the collector exposes to the fleet. Nests entries by host and entry name. ''; } ) definitions; }; collected = data // { join = host: entry: lib.filterAttrs (_name: value: value != null) ( lib.mapAttrs ( registryName: _registry: (data.${registryName}.${host} or { }).${entry} or null ) definitions ); }; }