nixos-config/nixos/components/network/zerotier.nix

27 lines
716 B
Nix
Raw Normal View History

2024-06-06 01:48:15 +02:00
{ lib, config, ... }:
let
machineDir = "${config.clanCore.clanDir}/machines/";
publicKey = machine: (builtins.readFile "${machineDir}/${machine}/facts/ssh.id_ed25519.pub");
machinesFileSet = builtins.readDir machineDir;
machines = lib.mapAttrsToList (name: _: name) machinesFileSet;
tld = config.clan.static-hosts.topLevelDomain;
knownHosts = lib.mapAttrs
(name: _:
{
hostNames = [
"[${name}]:2222"
"[${name}.${tld}]:2222"
"[${name}.private]:2222"
"${name}"
"${name}.${tld}"
"${name}.private"
];
publicKey = publicKey name;
}
)
machinesFileSet;
in
{
services.openssh.knownHosts = knownHosts;
}