2024-08-29 03:26:04 +02:00
|
|
|
{
|
|
|
|
lib,
|
|
|
|
config,
|
|
|
|
clanLib,
|
|
|
|
...
|
|
|
|
}:
|
2024-06-26 03:00:17 +02:00
|
|
|
with lib;
|
|
|
|
with types;
|
2024-06-06 01:48:15 +02:00
|
|
|
let
|
2024-06-06 11:56:18 +02:00
|
|
|
machines = clanLib.allMachineNames;
|
|
|
|
publicKey = clanLib.readFact "ssh.id_ed25519.pub";
|
2024-06-06 01:48:15 +02:00
|
|
|
tld = config.clan.static-hosts.topLevelDomain;
|
2024-08-29 03:26:04 +02:00
|
|
|
knownHosts = lib.genAttrs machines (machine: {
|
|
|
|
hostNames = [
|
|
|
|
"${machine}"
|
|
|
|
"${machine}.${tld}"
|
|
|
|
"${machine}.private"
|
|
|
|
];
|
|
|
|
publicKey = publicKey machine;
|
|
|
|
});
|
2024-08-08 19:25:19 +02:00
|
|
|
bootMachines = clanLib.readFactFromAllMachines "ssh.boot.id_ed25519.pub";
|
2024-08-29 03:26:04 +02:00
|
|
|
knownBootHosts = lib.mapAttrs' (
|
|
|
|
machine: publicKey:
|
|
|
|
nameValuePair "boot_${machine}" {
|
|
|
|
inherit publicKey;
|
|
|
|
hostNames = [
|
|
|
|
"[${machine}]:2222"
|
|
|
|
"[${machine}.public]:2222"
|
|
|
|
];
|
|
|
|
}
|
|
|
|
) bootMachines;
|
2024-06-06 01:48:15 +02:00
|
|
|
in
|
|
|
|
{
|
2024-06-26 03:00:17 +02:00
|
|
|
|
2024-08-11 00:02:11 +02:00
|
|
|
# todo : move this to the proper place
|
2024-06-26 03:00:17 +02:00
|
|
|
options.components.network.zerotier = {
|
|
|
|
enable = mkOption {
|
|
|
|
type = bool;
|
|
|
|
default = false; # todo : properly set this
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf config.components.network.zerotier.enable {
|
2024-08-08 19:25:19 +02:00
|
|
|
services.openssh.knownHosts = knownHosts // knownBootHosts;
|
2024-06-26 03:00:17 +02:00
|
|
|
};
|
2024-06-06 01:48:15 +02:00
|
|
|
}
|