A list of entities in the Fudo Nix sphere
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
1.2 KiB

{ lib, entities, ... }:
with lib;
getHostSite = hostname:
let site-name = entities.hosts."${hostname}".site;
in entities.sites."${site-name}";
getHostDomain = hostname:
let domain-name = entities.hosts."${hostname}".domain;
in entities.domains."${domain-name}";
getHostRealm = hostname: (getHostDomain hostname).gssapi-realm;
getHostFqdn = hostname:
let hostDomain = entities.hosts."${hostname}".domain;
in "${hostname}.${hostDomain}";
getHostNetworkSettings = hostname:
hostDomain = entities.hosts."${hostname}".domain;
hostNetwork = entities.zones."${hostDomain}";
in hostNetwork.hosts."${hostname}";
getIfAttr = as: a: if hasAttr as a then getAttr as a else null;
getHostIpv4 = hostname:
getIfAttr "ipv4-address" (getHostNetworkSettings hostname);
getHostIpv6 = hostname:
getIfAttr "ipv6-address" (getHostNetworkSettings hostname);
getHostIps = hostname:
filter (o: o != null) [ (getHostIpv4 hostname) (getHostIpv6 hostname) ];
getDomainPostgresqlServer = domain:
getHostFqdn entities.domains."${domain}".postgresql-server;
in {
inherit getHostSite getHostDomain getHostRealm getHostFqdn getHostIpv4
getHostIpv6 getHostIps getDomainPostgresqlServer;