From cdff2240afc17e586ac9307910880e5bc554a123 Mon Sep 17 00:00:00 2001 From: Franck Cuny Date: Sat, 12 Feb 2022 09:40:22 -0800 Subject: hosts: centralize network configuration --- hosts/carmel/default.nix | 25 +++++++++++++++---------- hosts/commons/default.nix | 3 +++ hosts/commons/network.nix | 19 +++++++++++++++++++ 3 files changed, 37 insertions(+), 10 deletions(-) create mode 100644 hosts/commons/network.nix (limited to 'hosts') diff --git a/hosts/carmel/default.nix b/hosts/carmel/default.nix index 11105d3..dcc1c7a 100644 --- a/hosts/carmel/default.nix +++ b/hosts/carmel/default.nix @@ -14,19 +14,24 @@ time.timeZone = "America/Los_Angeles"; - networking.hostName = hostname; - - networking.wireless.enable = false; - networking.interfaces.enp9s0.useDHCP = true; - networking.interfaces.wlp8s0.useDHCP = true; - # TODO: If set to false, systemd hangs on boot, unclear why. - services.xserver.dpi = 168; - # Use systemd-resolved - services.resolved = { + # Use systemd-networkd for networking + systemd.network = { enable = true; - dnssec = "false"; + networks = { + enp9s0 = { + matchConfig.Name = "enp9s0"; + networkConfig = { + DHCP = "yes"; + }; + extraConfig = '' + [DHCPv4] + UseDNS=yes + UseDomains=yes + ''; + }; + }; }; # This value determines the NixOS release from which the default diff --git a/hosts/commons/default.nix b/hosts/commons/default.nix index d49247a..d7773d4 100644 --- a/hosts/commons/default.nix +++ b/hosts/commons/default.nix @@ -1,6 +1,9 @@ { config, pkgs, system, inputs, ... }: { + imports = [ + ./network.nix + ] environment = { # Activate home-manager environment, if not already enabled loginShellInit = '' diff --git a/hosts/commons/network.nix b/hosts/commons/network.nix new file mode 100644 index 0000000..c44f7a4 --- /dev/null +++ b/hosts/commons/network.nix @@ -0,0 +1,19 @@ +{ config, pkgs, hostname, ... }: + +{ + networking = { + hostName = hostname; + useNetworkd = true; + wireless.enable = false; + useDHCP = false; + }; + + services.nscd.enable = false; + system.nssModules = lib.mkForce [ ]; + + # Use systemd-resolved + services.resolved = { + enable = true; + dnssec = "false"; + }; +} -- cgit 1.4.1