LnL7 / nix-darwin

nix modules for darwin
MIT License
3.19k stars 457 forks source link

Support configuring network locations #1048

Open tjni opened 2 months ago

tjni commented 2 months ago

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.

Below is a sample from my own configuration illustrating usage. I configure DNS servers on my Home location in order to bypass my AT&T router adding AT&T's DNS server automatically:

networking = {
  knownNetworkServices = ["Wi-Fi"];

  location = {
    Automatic = {};

    Home = {
      # to avoid AT&T's slow DNS servers
      dns = [
        "2001:4860:4860:0:0:0:0:8888"
        "2001:4860:4860:0:0:0:0:8844"
        "8.8.8.8"
        "8.8.4.4"
      ];
    };
  };
};
Enzime commented 2 months ago

Can you rebase this on master?

tjni commented 2 months ago

Done!