27 lines
716 B
Nix
27 lines
716 B
Nix
|
{ 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;
|
||
|
}
|