Files
nix-config/modules/nixos/base/networking/mdns.nix
T
Ryan Yin e4c2548a93 refactor: replace redundant mkForce with plain values and mkDefault
Each of these overrode a value nothing else set at a higher priority:

- qemu-guest: btrbk, hardwareTools and cloud-init have no competing
  definition on the guests.
- mdns: nixpkgs' sunshine module sets avahi.publish.* with mkDefault.
- computer-use: i18n now sets the time zone with mkDefault.
- darwin terminal: the shared ghostty/kitty font sizes are now mkDefault.
- shoukei: sunshine is mkDefault false in remote-desktop.nix, zram's
  memoryPercent is mkDefault 50; supportedFilesystems now merges instead
  of discarding the fsType entries other modules add.
- youko: nothing enables docker.
- nixpak: pasta.enable and sockets.pipewire are mkDefault in the shared
  modules, sockets.pulse already was.

Every NixOS host's toplevel drvPath is unchanged; on fern and frieren the
terminal font sizes and time zone evaluate to the same values.

Assisted-by: Claude Code (claude-opus-5-5)
2026-11-01 10:14:27 -06:00

50 lines
1.4 KiB
Nix

{
lib,
config,
...
}:
let
cfg = config.modules.mdns;
in
{
options.modules.mdns.enable =
lib.mkEnableOption ''
mDNS/DNS-SD responder, backed by avahi: `<hostname>.local` access and CUPS
printer discovery.
On by default for physical hosts; MicroVM guests turn it off since they
have nothing to advertise.
''
// {
default = true;
};
config = lib.mkIf cfg.enable {
# Network discovery on a local network, mDNS
# With this enabled, you can access your machine at <hostname>.local
# it's more convenient than using the IP address.
# https://avahi.org/
services.avahi = {
enable = true;
nssmdns4 = true;
settings.publish = {
disable-publishing = false;
disable-user-service-publishing = false;
publish-addresses = true;
publish-domain = true;
};
# The nixpkgs sunshine module still sets these legacy options (with
# mkDefault). Reset them to null so settings.publish above is the only
# source of truth.
publish.enable = null;
publish.userServices = null;
};
# avahi and systemd-resolved both run an mDNS responder, which makes mDNS
# unreliable ("Detected another IPv4/IPv6 mDNS stack running on this host").
# Keep avahi (needed for DNS-SD, e.g. CUPS printer discovery) and turn off
# resolved's own mDNS.
services.resolved.settings.Resolve.MulticastDNS = false;
};
}