fix: add public hostname to ssh config and refactor

This commit is contained in:
2026-02-02 18:34:39 +01:00
parent 4236aa1def
commit c538c5ad08
4 changed files with 35 additions and 34 deletions

View File

@@ -18,8 +18,20 @@ in
enable = true;
enableDefaultConfig = false;
matchBlocks = lib.genAttrs hostsWithKeys (hostname: {
host = hostname;
});
matchBlocks = lib.genAttrs hostsWithKeys (
hostname:
let
hostConfig = outputs.nixosConfigurations.${hostname}.config;
publicHostname = hostConfig.ssh.publicHostname;
targetUser = hostConfig.ssh.username;
in
{
host = hostname;
user = targetUser;
}
// lib.optionalAttrs (publicHostname != "") {
hostname = publicHostname;
}
);
};
}