Files
nix/modules/ssh/known-hosts.nix
T
hektor 14f8c83cf3
check / lint (push) Successful in 14s
refactor: simplify repo paths
2026-10-11 17:45:55 +02:00

22 lines
518 B
Nix

{
lib,
config,
outputs,
paths,
...
}:
let
hosts = lib.attrNames outputs.nixosConfigurations;
keyPath = hostname: paths.hosts + "/${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";
});
};
}