23 lines
780 B
Nix
23 lines
780 B
Nix
{
|
|
pkgs,
|
|
eth-interface ? "eth0",
|
|
static-ip ? false, # false, or IPv4 address as string
|
|
default-gateway ? "192.168.1.1",
|
|
}:
|
|
let static-ip-conf = if static-ip != false then {
|
|
networking.defaultGateway = { address = default-gateway; interface = eth-interface; };
|
|
networking.useDHCP = false;
|
|
networking.interfaces.${eth-interface}.ipv4.addresses = [ {
|
|
address = static-ip;
|
|
prefixLength = 24;
|
|
} ];
|
|
networking.networkmanager.unmanaged = [eth-interface];
|
|
} else {};
|
|
in pkgs.lib.attrsets.recursiveUpdate static-ip-conf
|
|
{
|
|
networking.networkmanager.enable = true;
|
|
networking.nameservers = [ "8.8.8.8" ];
|
|
networking.resolvconf.enable = true;
|
|
networking.resolvconf.dnsExtensionMechanism = false; # edns seems to be fucky with this enabled
|
|
}
|