-
-
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
151 additions
and
30 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, lib, ... }: | ||
|
||
{ | ||
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.escapeShellArg "Automatic"}" ${config.out}/activate | ||
grep "networksetup -setdnsservers ${lib.escapeShellArgs [ "Wi-Fi" "8.8.8.8" "8.8.4.4" ]}" ${config.out}/activate | ||
grep "networksetup -setdnsservers ${lib.escapeShellArgs [ "Thunderbolt Ethernet" "8.8.8.8" "8.8.4.4" ]}" ${config.out}/activate | ||
echo checking empty searchdomain settings in /activate >&2 | ||
grep "networksetup -switchtolocation ${lib.escapeShellArg "Home Lab"}" ${config.out}/activate | ||
grep "networksetup -setdnsservers ${lib.escapeShellArgs [ "Wi-Fi" "empty" ]}" ${config.out}/activate | ||
grep "networksetup -setdnsservers ${lib.escapeShellArgs [ "Thunderbolt Ethernet" "empty" ]}" ${config.out}/activate | ||
echo checking searchdomain settings in /activate >&2 | ||
grep "networksetup -setsearchdomains ${lib.escapeShellArgs [ "Wi-Fi" "empty" ]}" ${config.out}/activate | ||
grep "networksetup -setsearchdomains ${lib.escapeShellArgs [ "Thunderbolt Ethernet" "empty" ]}" ${config.out}/activate | ||
grep "networksetup -setsearchdomains ${lib.escapeShellArgs [ "Wi-Fi" "home.lab" ]}" ${config.out}/activate | ||
grep "networksetup -setsearchdomains ${lib.escapeShellArgs [ "Thunderbolt Ethernet" "home.lab" ]}" ${config.out}/activate | ||
''; | ||
} |