difftreelog
feat retrieve tagged hosts
in: trunk
1 file changed
modules/hosts.nixdiffbeforeafterboth1{1{2 lib,2 lib,3 fleetLib,3 fleetLib,4 config,4 ...5 ...5}: let6}: let6 inherit (fleetLib.modules) mkFleetGeneratorDefault;7 inherit (fleetLib.modules) mkFleetGeneratorDefault;7 inherit (fleetLib.types) mkHostsType mkDataType;8 inherit (fleetLib.types) mkHostsType mkDataType;8 inherit (lib.options) mkOption;9 inherit (lib.options) mkOption;9 inherit (lib.types) str listOf attrsOf submodule;10 inherit (lib.types) str listOf attrsOf submodule;11 inherit (lib.attrsets) mapAttrsToList mapAttrs;12 inherit (lib.lists) flatten groupBy;10in {13in {11 options = {14 options = {12 data = mkOption {15 data = mkOption {35 Usually used to persist fleet data between runs.38 Usually used to persist fleet data between runs.36 '';39 '';37 };40 };41 taggedWith = mkOption {42 type = attrsOf (listOf str);43 internal = true;44 };38 hosts = mkOption {45 hosts = mkOption {39 type = mkHostsType ({config, ...}: {46 type = mkHostsType ({config, ...}: {40 options = {47 options = {75 description = "Configurations of individual hosts";82 description = "Configurations of individual hosts";76 };83 };77 };84 };85 config.taggedWith = let86 hostTagList = flatten (mapAttrsToList (hostname: host: map (tag: {inherit hostname tag;}) host.tags) config.hosts);87 grouped = mapAttrs (_: hosts: lib.map (pair: pair.hostname) hosts) (groupBy (elem: elem.tag) hostTagList);88 in89 grouped;78 _file = ./meta.nix;90 _file = ./meta.nix;79}91}8092