2024-11-08 03:59:57 +00:00
|
|
|
lib: nixosConfigurations:
|
2023-03-17 04:21:32 +00:00
|
|
|
|
|
|
|
let
|
2024-11-08 03:59:57 +00:00
|
|
|
sshKnownHostsTxt = builtins.toFile "known_hosts" (
|
|
|
|
lib.concatMapStrings (
|
|
|
|
hostName:
|
|
|
|
let
|
|
|
|
d = nixosConfigurations.${hostName}.config.deploy;
|
|
|
|
in
|
|
|
|
lib.concatMapStrings (key: "${d.ssh.HostName} ${key}\n") d.sshPublicKeys
|
|
|
|
) (builtins.attrNames nixosConfigurations)
|
2023-03-17 04:21:32 +00:00
|
|
|
);
|
|
|
|
|
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
|
2024-11-08 03:59:57 +00:00
|
|
|
lib.concatMapStrings (host: ''
|
|
|
|
Host ${host}
|
|
|
|
UserKnownHostsFile ${sshKnownHostsTxt}
|
|
|
|
${attrsToLines nixosConfigurations.${host}.config.deploy.ssh}
|
|
|
|
'') (builtins.attrNames nixosConfigurations)
|