Merge pull request #121172 from eyJhb/bind-list-to-attrs
nixos/bind: refactor zones from a list to attrset
This commit is contained in:
commit
a221e6c330
@ -8,9 +8,13 @@ let
|
|||||||
|
|
||||||
bindUser = "named";
|
bindUser = "named";
|
||||||
|
|
||||||
bindZoneOptions = {
|
bindZoneCoerce = list: builtins.listToAttrs (lib.forEach list (zone: { name = zone.name; value = zone; }));
|
||||||
|
|
||||||
|
bindZoneOptions = { name, config, ... }: {
|
||||||
|
options = {
|
||||||
name = mkOption {
|
name = mkOption {
|
||||||
type = types.str;
|
type = types.str;
|
||||||
|
default = name;
|
||||||
description = "Name of the zone.";
|
description = "Name of the zone.";
|
||||||
};
|
};
|
||||||
master = mkOption {
|
master = mkOption {
|
||||||
@ -36,6 +40,7 @@ let
|
|||||||
default = "";
|
default = "";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
};
|
||||||
|
|
||||||
confFile = pkgs.writeText "named.conf"
|
confFile = pkgs.writeText "named.conf"
|
||||||
''
|
''
|
||||||
@ -84,7 +89,7 @@ let
|
|||||||
${extraConfig}
|
${extraConfig}
|
||||||
};
|
};
|
||||||
'')
|
'')
|
||||||
cfg.zones }
|
(attrValues cfg.zones) }
|
||||||
'';
|
'';
|
||||||
|
|
||||||
in
|
in
|
||||||
@ -153,18 +158,19 @@ in
|
|||||||
|
|
||||||
zones = mkOption {
|
zones = mkOption {
|
||||||
default = [];
|
default = [];
|
||||||
type = types.listOf (types.submodule [ { options = bindZoneOptions; } ]);
|
type = with types; coercedTo (listOf attrs) bindZoneCoerce (attrsOf (types.submodule bindZoneOptions));
|
||||||
description = "
|
description = "
|
||||||
List of zones we claim authority over.
|
List of zones we claim authority over.
|
||||||
";
|
";
|
||||||
example = [{
|
example = {
|
||||||
name = "example.com";
|
"example.com" = {
|
||||||
master = false;
|
master = false;
|
||||||
file = "/var/dns/example.com";
|
file = "/var/dns/example.com";
|
||||||
masters = ["192.168.0.1"];
|
masters = ["192.168.0.1"];
|
||||||
slaves = [];
|
slaves = [];
|
||||||
extraConfig = "";
|
extraConfig = "";
|
||||||
}];
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
extraConfig = mkOption {
|
extraConfig = mkOption {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user