[shared] Refactor systems

This commit is contained in:
2025-10-14 20:03:28 +02:00
parent 7cbab15cc9
commit af54dea18a
5 changed files with 141 additions and 156 deletions

View File

@@ -1,33 +1,28 @@
# /nix/store/<hash>/etc/ssh/ssh_config & /nix/store/<hash>/etc/ssh/authorized_keys
{
lib,
systemConfig,
systems,
knownSystems,
common,
...
}:
with builtins;
let
allSystems = knownSystems ++ systems;
allSystems = knownSystems // systems;
in
{
programs.ssh.knownHosts = listToAttrs (
map (system: {
name = system.hostName;
value = {
extraHostNames = [
(
if (system ? address && system.address ? tailnet) then
system.address.tailnet
else
common.tailnetAddr system.hostName
)
];
publicKey = system.ssh.publicKey;
};
}) allSystems
);
programs.ssh.knownHosts = builtins.mapAttrs (hostName: system: {
extraHostNames = [
(
if (system ? address && system.address ? tailnet) then
system.address.tailnet
else
common.tailnetAddr hostName
)
];
publicKey = system.ssh.publicKey;
}) allSystems;
users.users.${systemConfig.username}.openssh.authorizedKeys.keys = (
map (system: system.ssh.publicKey) allSystems
lib.mapAttrsToList (_hostName: system: system.ssh.publicKey) allSystems
);
}