{ packages }: { exports', ... }: { _class = "clan.service"; manifest.name = "clan-core/static-hosts"; manifest.description = "This is a test"; roles.default = { }; perMachine = { machine, roles, ... }: { nixosModule = { lib, ... }: let networks = lib.filter (n: n.networking != null) (builtins.attrValues exports'.instances); sortedNetworks = lib.lists.sort (p: q: p.priority < q.priority) networks; hostInNetwork = host: network: network ? ${host}; bestHost = host: (lib.findFirst (network: hostInNetwork host network) null sortedNetworks) .networking.peers.${host}.host.plain or null; in { networking.extraHosts = map (host: "${bestHost host} ${host}.clan") ( lib.attrNames roles.default.machines ); }; }; }