1
0
nixfiles/lib/clerie-monitoring-ids.nix

14 lines
531 B
Nix

inputs:
with inputs.nixpkgs.lib;
rec {
monitoringIdForHost = host: let
evalResult = builtins.tryEval (attrByPath [ "clerie" "monitoring" "id" ] null host.config);
in
if evalResult.success then evalResult.value else null;
monitoringIdsByHost = hosts: filterAttrs (name: id: id != null) (mapAttrs (name: host: monitoringIdForHost host) hosts);
hostsByMonitoringIds = hosts: mapAttrs' (name: id: nameValuePair id name) (monitoringIdsByHost hosts);
monitoringIds = hosts: attrNames (hostsByMonitoringIds hosts);
}