mirror of
https://github.com/nix-community/home-manager
synced 2024-11-26 21:19:45 +01:00
ssh: use list for conditional blocks
Sets do not guarantee order which is necessary for SSH configuration file semantics. Instead use a list of conditional block. Each conditional block must contain a `host` field, which will be used for the block condition.
This commit is contained in:
parent
5770af8fd8
commit
a78f9f9d1c
1 changed files with 14 additions and 7 deletions
|
@ -8,8 +8,15 @@ let
|
|||
|
||||
yn = flag: if flag then "yes" else "no";
|
||||
|
||||
hostModule = types.submodule ({...}: {
|
||||
matchBlockModule = types.submodule ({...}: {
|
||||
options = {
|
||||
host = mkOption {
|
||||
type = types.str;
|
||||
example = "*.example.org";
|
||||
description = ''
|
||||
The host pattern used by this conditional block.
|
||||
'';
|
||||
};
|
||||
|
||||
port = mkOption {
|
||||
type = types.nullOr types.int;
|
||||
|
@ -80,8 +87,8 @@ let
|
|||
};
|
||||
});
|
||||
|
||||
hostStr = host: cf: concatStringsSep "\n" (
|
||||
["Host ${host}"]
|
||||
matchBlockStr = cf: concatStringsSep "\n" (
|
||||
["Host ${cf.host}"]
|
||||
++ optional (cf.port != null) " Port ${toString cf.port}"
|
||||
++ optional cf.forwardX11 " ForwardX11 yes"
|
||||
++ optional cf.forwardX11Trusted " ForwardX11Trusted yes"
|
||||
|
@ -125,9 +132,9 @@ in
|
|||
'';
|
||||
};
|
||||
|
||||
hosts = mkOption {
|
||||
type = types.attrsOf hostModule;
|
||||
default = {};
|
||||
matchBlocks = mkOption {
|
||||
type = types.listOf matchBlockModule;
|
||||
default = [];
|
||||
description = ''
|
||||
Specify per-host settings.
|
||||
'';
|
||||
|
@ -140,7 +147,7 @@ in
|
|||
ControlMaster ${cfg.controlMaster}
|
||||
ControlPath ${cfg.controlPath}
|
||||
|
||||
${concatStringsSep "\n\n" (mapAttrsToList hostStr cfg.hosts)}
|
||||
${concatStringsSep "\n\n" (map matchBlockStr cfg.matchBlocks)}
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue