-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #590 from nix-community/misc
Various fixes (macOS, mdns)
- Loading branch information
Showing
3 changed files
with
7 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,18 @@ | ||
{ config, lib, ... }: | ||
let | ||
# The default value of useDHCP for individual interfaces is null! | ||
mapInterfaceEnabled = i: lib.nameValuePair "40-${i.name}" (i.useDHCP == true); | ||
mapMDNSConfig = enableMDNS: { | ||
networkConfig.MulticastDNS = lib.mkDefault enableMDNS; | ||
}; | ||
|
||
configs = { | ||
"99-ethernet-default-dhcp" = config.networking.useDHCP; | ||
"99-wireless-client-dhcp" = config.networking.useDHCP; | ||
} // (lib.mapAttrs' (_: mapInterfaceEnabled) config.networking.interfaces); | ||
dhcpInterfaces = lib.filterAttrs (i: i.useDHCP == true) config.networking.interfaces; | ||
in | ||
{ | ||
# Avahi is an alternative implementation. If it's enabled, than we don't need the code below. | ||
config = lib.mkIf (!config.services.avahi.enable) { | ||
networking.firewall.allowedUDPPorts = [ 5353 ]; # Multicast DNS | ||
|
||
# Allows to find machines on the local network by name, i.e. useful for printer discovery | ||
systemd.network.networks = builtins.mapAttrs (_: mapMDNSConfig) configs; | ||
systemd.network.networks = | ||
lib.optionalAttrs (config.networking.useDHCP) { | ||
"99-ethernet-default-dhcp".networkConfig.MulticastDNS = lib.mkDefault true; | ||
"99-wireless-client-dhcp".networkConfig.MulticastDNS = lib.mkDefault true; | ||
} | ||
// builtins.mapAttrs (_: { networkConfig.MulticastDNS = lib.mkDefault true; }) dhcpInterfaces; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters