{ inputs, dnsNix, povSelf, config, lib, pkgs, ... }: let inherit (lib) types; cfg = lib.getAttrFromPath povSelf config; in { options = { enable = { type = types.bool; default = false; }; # contains dns entries defined on the local host zones = { type = types.attrsOf dnsNix.types.subzone; default = { }; }; # contains dns entries defined on the local host and on remote hosts, merged together allZones = { type = types.attrsOf dnsNix.types.zone; default = { }; }; zoneFiles = { type = types.attrsOf types.path; readOnly = true; default = ( cfg.allZones |> lib.mapAttrs ( name: zone: toString ( pkgs.writeTextFile { name = "${name}.zone"; text = dnsNix.types.zoneToString name (dnsNix.evalZone name zone); } ) ) ); }; }; config = lib.mkIf cfg.enable { # serve records defined in all host configs dns.allZones = lib.mkMerge ( inputs.self.nixosConfigurations |> lib.mapAttrsToList (hostName: hostConfig: hostConfig.config.dns.zones) ); }; }