How to make systemd-resolved and mDNS work together?

I enabled mDNS with

 services.avahi = {
  nssmdns = true;
  enable = true;
  ipv4 = true;
  ipv6 = true;
  publish = {
    enable = true;
    addresses = true;
    workstation = true;

Originally, this works fine, I can access my network neighbours by their host names.

Then I enable the systemd-resolved with

        enable = true;
        fallbackDns = [

Then my mDNS does not work.

I search the web pages e.g., the archlinux wiki, and find that some settings have to be set, for example, the MulticastDNS= in resolved.conf, mdns= in the [connection] section of networkmanager (yes, I’m using NetworkManager to manage my network).

But these settings seem not available in nixos’s options.


I think you might be running into this bug: mdns support for nss does not work when networkd is enabled · Issue #98050 · NixOS/nixpkgs · GitHub

It’s fixed on the master branch but not in the 20.09 release (which is the latest stable release):