Janik-Haag / NixOS-DNS

Manage your dns zones with NixOS
MIT License
122 stars 3 forks source link

`subDomains` working as not expected from docs #16

Open Rubikoid opened 3 months ago

Rubikoid commented 3 months ago

According to subDomains -> matches table at docs, I thought the next configuration

(
  let
    rootZone = "example.org";
  in
  {
    networking.domains = {
      enable = true;
      defaultTTL = 86400; # 24h
      baseDomains."nodes.${rootZone}" = { };
      baseDomains."${rootZone}" = { };
      subDomains."xxx.nodes.${rootZone}".a.data = [ "1.1.1.1" ];
      subDomains."yyy.${rootZone}".cname.data = [ "xxx.nodes.${rootZone}" ];
    };
  }
)

will evaluate to something like that

{
  "nodes.example.org" = {
    "xxx.nodes.example.org" = {
      a = {
        data = [ "1.1.1.1" ];
        ttl = 86400;
      };
    };
  };
  "example.org" = {
    "yyy.example.org" = {
      cname = {
        data = [ "xxx.nodes.example.org" ];
        ttl = 86400;
      };
    };
  };
}

But in real on the latest master this evaluates to:

{
  "example.org" = {
    "xxx.nodes.example.org" = {
      a = {
        data = [ "1.1.1.1" ];
        ttl = 86400;
      };
    };
    "yyy.example.org" = {
      cname = {
        data = [ "xxx.nodes.example.org" ];
        ttl = 86400;
      };
    };
  };
}

So, the baseDomains."nodes.${rootZone}" = { }; line makes no changes whenever it exists or not.

As how Im traced, this happens due to reducedBaseDomains. Is this intended?

Also there is an error in code block before table, networking.domains.baseDomains should be replaced with networking.domains.subDomains, otherwise this sample makes no sense.

Janik-Haag commented 3 months ago

I'll look into this in a bit once I have more time, thank you very much for the report, but yes you are right, this seems like a bug.