nixos/bind: refactor zones from a list to attrset
This commit uses coercedTo to make zones a attrset instead of list. Makes it easier to access/change zones in multiple places.
This commit is contained in:
parent
2bd34a98af
commit
757a455dde
@ -8,32 +8,37 @@ let
|
|||||||
|
|
||||||
bindUser = "named";
|
bindUser = "named";
|
||||||
|
|
||||||
bindZoneOptions = {
|
bindZoneCoerce = list: builtins.listToAttrs (lib.forEach list (zone: { name = zone.name; value = zone; }));
|
||||||
name = mkOption {
|
|
||||||
type = types.str;
|
bindZoneOptions = { name, config, ... }: {
|
||||||
description = "Name of the zone.";
|
options = {
|
||||||
};
|
name = mkOption {
|
||||||
master = mkOption {
|
type = types.str;
|
||||||
description = "Master=false means slave server";
|
default = name;
|
||||||
type = types.bool;
|
description = "Name of the zone.";
|
||||||
};
|
};
|
||||||
file = mkOption {
|
master = mkOption {
|
||||||
type = types.either types.str types.path;
|
description = "Master=false means slave server";
|
||||||
description = "Zone file resource records contain columns of data, separated by whitespace, that define the record.";
|
type = types.bool;
|
||||||
};
|
};
|
||||||
masters = mkOption {
|
file = mkOption {
|
||||||
type = types.listOf types.str;
|
type = types.either types.str types.path;
|
||||||
description = "List of servers for inclusion in stub and secondary zones.";
|
description = "Zone file resource records contain columns of data, separated by whitespace, that define the record.";
|
||||||
};
|
};
|
||||||
slaves = mkOption {
|
masters = mkOption {
|
||||||
type = types.listOf types.str;
|
type = types.listOf types.str;
|
||||||
description = "Addresses who may request zone transfers.";
|
description = "List of servers for inclusion in stub and secondary zones.";
|
||||||
default = [];
|
};
|
||||||
};
|
slaves = mkOption {
|
||||||
extraConfig = mkOption {
|
type = types.listOf types.str;
|
||||||
type = types.str;
|
description = "Addresses who may request zone transfers.";
|
||||||
description = "Extra zone config to be appended at the end of the zone section.";
|
default = [];
|
||||||
default = "";
|
};
|
||||||
|
extraConfig = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
description = "Extra zone config to be appended at the end of the zone section.";
|
||||||
|
default = "";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -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…
Reference in New Issue
Block a user