mirror of
https://github.com/buckley310/nixos-config.git
synced 2024-11-09 18:47:02 +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
|
sshKnownHostsTxt = builtins.toFile "known_hosts" (lib.concatMapStrings
|
||||||
(hostName:
|
(hostName:
|
||||||
let d = nixosConfigurations.${hostName}.config.deploy;
|
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)
|
(builtins.attrNames nixosConfigurations)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
attrsToList = lib.mapAttrsToList (n: v: "${n} ${v}");
|
||||||
|
attrsToLines = a: lib.concatLines (attrsToList a);
|
||||||
|
|
||||||
in
|
in
|
||||||
builtins.toFile "ssh-config" (''
|
builtins.toFile "ssh-config" (''
|
||||||
StrictHostKeyChecking yes
|
StrictHostKeyChecking yes
|
||||||
|
@ -18,6 +21,6 @@ builtins.toFile "ssh-config" (''
|
||||||
lib.concatMapStrings
|
lib.concatMapStrings
|
||||||
(host: ''
|
(host: ''
|
||||||
Host ${host}
|
Host ${host}
|
||||||
HostName ${nixosConfigurations.${host}.config.deploy.targetHost}
|
${attrsToLines nixosConfigurations.${host}.config.deploy.ssh}
|
||||||
'')
|
'')
|
||||||
(builtins.attrNames nixosConfigurations))
|
(builtins.attrNames nixosConfigurations))
|
||||||
|
|
|
@ -4,8 +4,8 @@
|
||||||
sshPublicKeys = lib.mkOption {
|
sshPublicKeys = lib.mkOption {
|
||||||
type = lib.types.listOf lib.types.str;
|
type = lib.types.listOf lib.types.str;
|
||||||
};
|
};
|
||||||
targetHost = lib.mkOption {
|
ssh = lib.mkOption {
|
||||||
type = lib.types.str;
|
type = lib.types.attrsOf lib.types.str;
|
||||||
};
|
};
|
||||||
tags = lib.mkOption {
|
tags = lib.mkOption {
|
||||||
type = lib.types.listOf lib.types.str;
|
type = lib.types.listOf lib.types.str;
|
||||||
|
|
Loading…
Reference in a new issue