Unverified Commit 672d1034 authored by Florian Klink's avatar Florian Klink Committed by GitHub
Browse files

Merge pull request #258424 from SuperSandro2000/nss-mdns-timeout

nixos/avahi-daemon: resolve mdns over only over ipv4
parents 73794db4 bba808db
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -32,6 +32,9 @@ The pre-existing [services.ankisyncd](#opt-services.ankisyncd.enable) has been m
- `mkosi` was updated to v19. Parts of the user interface have changed. Consult the
  [release notes](https://github.com/systemd/mkosi/releases/tag/v19) for a list of changes.

- `services.avahi.nssmdns` got split into `services.avahi.nssmdns4` and `services.avahi.nssmdns6` which enable the mDNS NSS switch for IPv4 and IPv6 respectively.
  Since most mDNS responders only register IPv4 addresses, most users want to keep the IPv6 support disabled to avoid long timeouts.

## Other Notable Changes {#sec-release-24.05-notable-changes}

<!-- To avoid merge conflicts, consider adding your item at an arbitrary place in the list instead. -->
+30 −5
Original line number Diff line number Diff line
@@ -42,6 +42,7 @@ in
{
  imports = [
    (lib.mkRenamedOptionModule [ "services" "avahi" "interfaces" ] [ "services" "avahi" "allowInterfaces" ])
    (lib.mkRenamedOptionModule [ "services" "avahi" "nssmdns" ] [ "services" "avahi" "nssmdns4" ])
  ];

  options.services.avahi = {
@@ -93,7 +94,7 @@ in

    ipv6 = mkOption {
      type = types.bool;
      default = config.networking.enableIPv6;
      default = false;
      defaultText = literalExpression "config.networking.enableIPv6";
      description = lib.mdDoc "Whether to use IPv6.";
    };
@@ -218,13 +219,28 @@ in
      };
    };

    nssmdns = mkOption {
    nssmdns4 = mkOption {
      type = types.bool;
      default = false;
      description = lib.mdDoc ''
        Whether to enable the mDNS NSS (Name Service Switch) plug-in for IPv4.
        Enabling it allows applications to resolve names in the `.local`
        domain by transparently querying the Avahi daemon.
      '';
    };

    nssmdns6 = mkOption {
      type = types.bool;
      default = false;
      description = lib.mdDoc ''
        Whether to enable the mDNS NSS (Name Service Switch) plug-in.
        Whether to enable the mDNS NSS (Name Service Switch) plug-in for IPv6.
        Enabling it allows applications to resolve names in the `.local`
        domain by transparently querying the Avahi daemon.

        ::: {.note}
        Due to the fact that most mDNS responders only register local IPv4 addresses,
        most user want to leave this option disabled to avoid long timeouts when applications first resolve the none existing IPv6 address.
        :::
      '';
    };

@@ -257,8 +273,17 @@ in
    users.groups.avahi = { };

    system.nssModules = optional cfg.nssmdns pkgs.nssmdns;
    system.nssDatabases.hosts = optionals cfg.nssmdns (mkMerge [
      (mkBefore [ "mdns_minimal [NOTFOUND=return]" ]) # before resolve
    system.nssDatabases.hosts = let
      mdnsMinimal = if (cfg.nssmdns4 && cfg.nssmdns6) then
        "mdns_minimal"
      else if (!cfg.nssmdns4 && cfg.nssmdns6) then
        "mdns6_minimal"
      else if (cfg.nssmdns4 && !cfg.nssmdns6) then
        "mdns4_minimal"
      else
        "";
    in optionals (cfg.nssmdns4 || cfg.nssmdns6) (mkMerge [
      (mkBefore [ "${mdnsMinimal} [NOTFOUND=return]" ]) # before resolve
      (mkAfter [ "mdns" ]) # after dns
    ]);