mirror of
https://github.com/ryan4yin/nix-config.git
synced 2026-11-20 14:31:28 +01:00
44 lines
1.1 KiB
Nix
44 lines
1.1 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;
|
|
publish = {
|
|
enable = true;
|
|
domain = true;
|
|
userServices = true;
|
|
};
|
|
};
|
|
|
|
# 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;
|
|
};
|
|
}
|