Rename 'network' to 'zone' to be less ambiguous

This commit is contained in:
niten 2021-11-22 11:22:57 -08:00
parent f3c4e626d0
commit 0ef91c51ea
6 changed files with 34 additions and 29 deletions

View File

@ -21,9 +21,9 @@ let
default = null;
};
network-definition = mkOption {
type = submodule (import ../types/network-definition.nix);
description = "Definition of network to be served by local server.";
zone-definition = mkOption {
type = submodule (import ../types/zone-definition.nix);
description = "Definition of network zone to be served by local server.";
};
default-host = mkOption {
@ -139,7 +139,7 @@ in {
interfaces = cfg.listen-ips;
stateDir = cfg.state-directory;
zones = mapAttrs' (dom: dom-cfg: let
net-cfg = dom-cfg.network-definition;
net-cfg = dom-cfg.zone-definition;
in nameValuePair "${dom}." {
dnssec = dom-cfg.dnssec;

View File

@ -77,6 +77,12 @@ let
description = "Hostname of the primary mail server for this domain.";
default = null;
};
zone = mkOption {
type = nullOr str;
description = "Name of the DNS zone associated with domain.";
default = null;
};
};
};

View File

@ -66,13 +66,11 @@ in {
(hostname: hostOpts: hostOpts.initrd-network != null)
config.instance.local-hosts;
in {
network-definition.hosts = mapAttrs'
(hostname: hostOpts: nameValuePair "${hostname}-recovery"
{
ipv4-address = hostOpts.initrd-network.ip;
description = "${hostname} initrd host";
})
initrd-network-hosts;
zone-definition.hosts = mapAttrs'
(hostname: hostOpts: nameValuePair "${hostname}-recovery" {
ipv4-address = hostOpts.initrd-network.ip;
description = "${hostname} initrd host";
}) initrd-network-hosts;
extra-records = let
recs = (mapAttrsToList

View File

@ -74,11 +74,11 @@ in {
default = [ ];
};
network-definition = let
networkOpts = import ../types/network-definition.nix { inherit lib; };
zone-definition = let
zoneOpts = import ../types/zone-definition.nix { inherit lib; };
in mkOption {
type = submodule networkOpts;
description = "Definition of network to be served by local server.";
type = submodule zoneOpts;
description = "Definition of network zone to be served by local server.";
default = { };
};
@ -94,12 +94,13 @@ in {
fudo.system.hostfile-entries = let
other-hosts = filterAttrs
(hostname: hostOpts: hostname != config.instance.hostname)
cfg.network-definition.hosts;
cfg.zone-definition.hosts;
in mapAttrs' (hostname: hostOpts:
nameValuePair hostOpts.ipv4-address ["${hostname}.${cfg.domain}" hostname])
other-hosts;
services.dhcpd4 = let network = cfg.network-definition;
services.dhcpd4 = let
zone = cfg.zone-definition;
in {
enable = true;
@ -109,7 +110,7 @@ in {
ipAddress = hostOpts.ipv4-address;
}) (filterAttrs (host: hostOpts:
hostOpts.mac-address != null && hostOpts.ipv4-address != null)
network.hosts);
zone.hosts);
interfaces = cfg.dhcp-interfaces;
@ -163,7 +164,7 @@ in {
ipToBlock = ip:
concatStringsSep "." (reverseList (take 3 (splitString "." ip)));
compactHosts =
mapAttrsToList (host: data: data // { host = host; }) network.hosts;
mapAttrsToList (host: data: data // { host = host; }) zone.hosts;
hostsByBlock =
groupBy (host-data: ipToBlock host-data.ipv4-address) compactHosts;
hostPtrRecord = host-data:
@ -184,7 +185,7 @@ in {
(map (sshfp: "${host} IN SSHFP ${sshfp}") ssh-fingerprints);
cnameRecord = alias: host: "${alias} IN CNAME ${host}";
network = cfg.network-definition;
zone = cfg.zone-definition;
known-hosts = config.fudo.hosts;
@ -219,17 +220,17 @@ in {
$TTL 30m
${optionalString (network.gssapi-realm != null)
''_kerberos IN TXT "${network.gssapi-realm}"''}
${optionalString (zone.gssapi-realm != null)
''_kerberos IN TXT "${zone.gssapi-realm}"''}
${join-lines
(imap1 (i: server-ip: "ns${toString i} IN A ${server-ip}")
cfg.dns-servers)}
${join-lines (mapAttrsToList hostARecord network.hosts)}
${join-lines (mapAttrsToList hostSshFpRecords network.hosts)}
${join-lines (mapAttrsToList cnameRecord network.aliases)}
${join-lines network.verbatim-dns-records}
${pkgs.lib.fudo.dns.srvRecordsToBindZone network.srv-records}
${join-lines (mapAttrsToList hostARecord zone.hosts)}
${join-lines (mapAttrsToList hostSshFpRecords zone.hosts)}
${join-lines (mapAttrsToList cnameRecord zone.aliases)}
${join-lines zone.verbatim-dns-records}
${pkgs.lib.fudo.dns.srvRecordsToBindZone zone.srv-records}
${join-lines cfg.extra-records}
'';
}] ++ blockZones;

View File

@ -3,7 +3,7 @@
with lib;
let
zoneOpts =
import ../types/network-definition.nix { inherit lib; };
import ../types/zone-definition.nix { inherit lib; };
in {
options.fudo.zones = with types; mkOption {
type = attrsOf (submodule zoneOpts);

View File

@ -101,7 +101,7 @@ in {
gssapi-realm = mkOption {
type = nullOr str;
description = "Kerberos GSSAPI realm of the network.";
description = "Kerberos GSSAPI realm of the zone.";
default = null;
};
};