How to use a nameserver with a static networking configuration?


I’m not sure if what I’m encountering is a bug (so I’m first asking here before creating a github issue).

I currently have problems with resolving domains on my server (which runs on NixOS 20.09), probably best explained by the config:

  networking = {
    useDHCP = false;
    interfaces.ens3.useDHCP = false;
    interfaces.ens3.ipv4.addresses = [{
      address = "<myaddress>";
      prefixLength = 22;
    defaultGateway = "<mygateway>";
    nameservers = [ "" "" "" ];
    hostName = "<myhostname>";

This is I guess the relevant section I’ve configured.
I thought that the nameservers are generated into the resolv.conf (which I manually put in to test, which fixed my issue with dns resolving).

But it seems there is no nameserver added into the /etc/resolv.conf with this configuration.
On my desktop configuration, where I’m using Networkmanager and DHCP /etc/resolv.conf is correctly injecting the nameservers I’ve configured in networking.nameservers.

Ok, I’ve found my issue:

I’m also using simple-nixos-mailserver / nixos-mailserver · GitLab
which is configured by default with this: localDnsResolver = true, this replaces the nameservers config with [ "" ] and thus all my nameservers are gone and replaced with localhost.
I’ve set it to false for now, which fixes my issue.

I’ve created an issue in nixos-mailserver, if anyone else is running into this: