mirror of https://gitlab.crans.org/nounous/nixos
55 lines
1017 B
Nix
55 lines
1017 B
Nix
{
|
|
infra,
|
|
lib,
|
|
hosts,
|
|
...
|
|
}:
|
|
let
|
|
inherit (lib)
|
|
attrNames
|
|
concatMap
|
|
optional
|
|
mapAttrs'
|
|
mkIf
|
|
nameValuePair
|
|
;
|
|
in
|
|
{
|
|
services.openssh = {
|
|
enable = true;
|
|
|
|
settings = {
|
|
PermitRootLogin = "yes";
|
|
};
|
|
|
|
# knownHosts :
|
|
# {
|
|
# "host" = {
|
|
# hostNames = ["host.adm.crans.org" 172.16.10.2 …]
|
|
# publicKey = "ssh-ed25519…"
|
|
# }
|
|
# }
|
|
knownHosts = mapAttrs' (
|
|
n: conf:
|
|
nameValuePair n (
|
|
mkIf (conf.publicSsh != null) {
|
|
publicKey = conf.publicSsh;
|
|
|
|
hostNames = [
|
|
"${n}.adm.crans.org"
|
|
]
|
|
++ concatMap (
|
|
vlan:
|
|
let
|
|
netv = conf.networking.${vlan};
|
|
in
|
|
optional (netv.enable && (netv.ipv4.address or null) != null) netv.ipv4.address
|
|
++ optional (netv.enable && (netv.ipv6.address or null) != null) netv.ipv6.address
|
|
) (attrNames infra.vlans);
|
|
}
|
|
)
|
|
) hosts;
|
|
|
|
};
|
|
}
|