gen-ssh-config: allow arbitrary ssh configs

This commit is contained in:
Sean Buckley 2023-06-11 14:20:11 -04:00
parent ccc9e1a8d0
commit c3e64d4b84
2 changed files with 7 additions and 4 deletions

View file

@ -5,11 +5,14 @@ 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
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
@ -18,6 +21,6 @@ builtins.toFile "ssh-config" (''
lib.concatMapStrings
(host: ''
Host ${host}
HostName ${nixosConfigurations.${host}.config.deploy.targetHost}
${attrsToLines nixosConfigurations.${host}.config.deploy.ssh}
'')
(builtins.attrNames nixosConfigurations))

View file

@ -4,8 +4,8 @@
sshPublicKeys = lib.mkOption {
type = lib.types.listOf lib.types.str;
};
targetHost = lib.mkOption {
type = lib.types.str;
ssh = lib.mkOption {
type = lib.types.attrsOf lib.types.str;
};
tags = lib.mkOption {
type = lib.types.listOf lib.types.str;