mirror of
https://github.com/buckley310/nixos-config.git
synced 2024-12-21 19:24:15 +00:00
gen-ssh-config: allow arbitrary ssh configs
This commit is contained in:
parent
ccc9e1a8d0
commit
c3e64d4b84
2 changed files with 7 additions and 4 deletions
|
@ -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))
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue