Files
nix/modules/ssh/known-hosts.nix
T
hektor 6fa74fead8
check / lint (push) Successful in 15s
refactor: rename utils to lib'
2026-11-06 14:35:01 +01:00

21 lines
483 B
Nix

{
lib,
config,
lib',
...
}:
let
hosts = lib'.nixosHosts;
keyPath = hostname: lib'.hostsPath + "/${hostname}/ssh_host.pub";
hostsWithKeys = lib.filter (hostname: builtins.pathExists (keyPath hostname)) hosts;
in
{
config = lib.mkIf config.ssh.enable {
programs.ssh.knownHosts = lib.genAttrs hostsWithKeys (hostname: {
publicKeyFile = keyPath hostname;
extraHostNames = lib.optional (hostname == config.networking.hostName) "localhost";
});
};
}