{ lib, config, pkgs, ... }: with lib; let cfg = config.local; in { options.local = with lib.types; { hostname = mkOption { type = str; }; dhcpInterface = mkOption { type = nullOr str; default = null; }; }; config = { environment.systemPackages = [ pkgs.dhcpcd ]; networking = { hostName = cfg.hostname; useDHCP = false; useNetworkd = true; wireguard.enable = true; }; systemd.network.networks."40-${cfg.dhcpInterface}" = mkIf (cfg.dhcpInterface != null) { matchConfig.Name = cfg.dhcpInterface; networkConfig = { DHCP = "ipv4"; IPv6AcceptRA = true; IPv6PrivacyExtensions = "kernel"; }; # make routing on this interface a dependency for network-online.target linkConfig.RequiredForOnline = "routable"; }; }; }