mirror of
https://github.com/buckley310/nixos-config.git
synced 2024-12-21 19:24:15 +00:00
24 lines
598 B
Nix
24 lines
598 B
Nix
|
lib:
|
||
|
nixosConfigurations:
|
||
|
|
||
|
let
|
||
|
sshKnownHostsTxt = builtins.toFile "known_hosts" (lib.concatMapStrings
|
||
|
(hostName:
|
||
|
let d = nixosConfigurations.${hostName}.config.deploy;
|
||
|
in lib.concatMapStrings (key: "${d.targetHost} ${key}\n") d.sshPublicKeys
|
||
|
)
|
||
|
(builtins.attrNames nixosConfigurations)
|
||
|
);
|
||
|
|
||
|
in
|
||
|
builtins.toFile "ssh-config" (''
|
||
|
StrictHostKeyChecking yes
|
||
|
GlobalKnownHostsFile ${sshKnownHostsTxt}
|
||
|
'' +
|
||
|
lib.concatMapStrings
|
||
|
(host: ''
|
||
|
Host ${host}
|
||
|
HostName ${nixosConfigurations.${host}.config.deploy.targetHost}
|
||
|
'')
|
||
|
(builtins.attrNames nixosConfigurations))
|