2023-03-17 04:21:32 +00:00
|
|
|
lib:
|
|
|
|
nixosConfigurations:
|
|
|
|
|
|
|
|
let
|
|
|
|
sshKnownHostsTxt = builtins.toFile "known_hosts" (lib.concatMapStrings
|
|
|
|
(hostName:
|
|
|
|
let d = nixosConfigurations.${hostName}.config.deploy;
|
2023-06-11 18:20:11 +00:00
|
|
|
in lib.concatMapStrings (key: "${d.ssh.HostName} ${key}\n") d.sshPublicKeys
|
2023-03-17 04:21:32 +00:00
|
|
|
)
|
|
|
|
(builtins.attrNames nixosConfigurations)
|
|
|
|
);
|
|
|
|
|
2023-06-11 18:20:11 +00:00
|
|
|
attrsToList = lib.mapAttrsToList (n: v: "${n} ${v}");
|
|
|
|
attrsToLines = a: lib.concatLines (attrsToList a);
|
|
|
|
|
2023-03-17 04:21:32 +00:00
|
|
|
in
|
2023-07-07 19:34:00 +00:00
|
|
|
builtins.toFile "ssh-config" (
|
|
|
|
lib.concatMapStrings
|
|
|
|
(host: ''
|
|
|
|
Host ${host}
|
2023-12-04 16:10:11 +00:00
|
|
|
UserKnownHostsFile ${sshKnownHostsTxt}
|
|
|
|
${attrsToLines nixosConfigurations.${host}.config.deploy.ssh}
|
2023-07-07 19:34:00 +00:00
|
|
|
'')
|
2023-09-01 22:57:58 +00:00
|
|
|
(builtins.attrNames nixosConfigurations)
|
2023-07-07 19:34:00 +00:00
|
|
|
)
|