-
-
Notifications
You must be signed in to change notification settings - Fork 457
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support configuring network locations.
This adds support for configuring DNS servers and search domains for each location. This is exposed through the networking.location option. The networking.knownNetworkServices option now applies globally across all locations. The networking.dns and networking.search options are now aliases under networking.location.Automatic, since the "Automatic" network location is the default location on an unconfigured system.
- Loading branch information
Showing
2 changed files
with
117 additions
and
29 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,15 +1,35 @@ | ||
{ config, pkgs, ... }: | ||
{ lib, config, ... }: | ||
|
||
{ | ||
networking.knownNetworkServices = [ "Wi-Fi" "Thunderbolt Ethernet" ]; | ||
networking.dns = [ "8.8.8.8" "8.8.4.4" ]; | ||
networking.knownNetworkServices = [ | ||
"Wi-Fi" | ||
"Thunderbolt Ethernet" | ||
]; | ||
networking.dns = [ | ||
"8.8.8.8" | ||
"8.8.4.4" | ||
]; | ||
networking.location."Home Lab" = { | ||
search = [ "home.lab" ]; | ||
}; | ||
|
||
test = '' | ||
echo checking dns settings in /activate >&2 | ||
grep "networksetup -switchtolocation ${lib.strings.escapeShellArg "Automatic"}" ${config.out}/activate | ||
grep "networksetup -setdnsservers 'Wi-Fi' '8.8.8.8' '8.8.4.4'" ${config.out}/activate | ||
grep "networksetup -setdnsservers 'Thunderbolt Ethernet' '8.8.8.8' '8.8.4.4'" ${config.out}/activate | ||
echo checking empty searchdomain settings in /activate >&2 | ||
grep "networksetup -switchtolocation 'Home Lab'" ${config.out}/activate | ||
grep "networksetup -setdnsservers 'Wi-Fi' 'empty'" ${config.out}/activate | ||
grep "networksetup -setdnsservers 'Thunderbolt Ethernet' 'empty'" ${config.out}/activate | ||
echo checking searchdomain settings in /activate >&2 | ||
grep "networksetup -setsearchdomains 'Wi-Fi' 'empty'" ${config.out}/activate | ||
grep "networksetup -setsearchdomains 'Thunderbolt Ethernet' 'empty'" ${config.out}/activate | ||
grep "networksetup -setsearchdomains 'Wi-Fi' 'home.lab'" ${config.out}/activate | ||
grep "networksetup -setsearchdomains 'Thunderbolt Ethernet' 'home.lab'" ${config.out}/activate | ||
''; | ||
} |