mirror of
https://github.com/buckley310/nixos-config.git
synced 2024-12-21 19:24:15 +00:00
26 lines
707 B
Nix
26 lines
707 B
Nix
lib:
|
|
nixosConfigurations:
|
|
|
|
let
|
|
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)
|
|
);
|
|
|
|
attrsToList = lib.mapAttrsToList (n: v: "${n} ${v}");
|
|
attrsToLines = a: lib.concatLines (attrsToList a);
|
|
|
|
in
|
|
builtins.toFile "ssh-config" (''
|
|
StrictHostKeyChecking yes
|
|
GlobalKnownHostsFile ${sshKnownHostsTxt}
|
|
'' +
|
|
lib.concatMapStrings
|
|
(host: ''
|
|
Host ${host}
|
|
${attrsToLines nixosConfigurations.${host}.config.deploy.ssh}
|
|
'')
|
|
(builtins.attrNames nixosConfigurations))
|