{ config, lib, ... }: with lib; with builtins; let networks = attrNames (readDir ./tinc/private); in { imports = map (network: (./tinc/private + "/${network}")) networks; services.tinc.networks = genAttrs networks (network: { name = config.networking.hostName; hosts = let hosts = attrNames (readDir (./tinc/private + "/${network}/hosts")); config = hostname: readFile (./tinc/private + "/${network}/hosts/${hostname}"); in genAttrs hosts config; }); }