2023-10-21 12:56:02 +02:00
|
|
|
{
|
2024-06-23 22:43:00 +02:00
|
|
|
pkgs,
|
2023-10-21 12:56:02 +02:00
|
|
|
eth-interface ? "eth0",
|
2024-06-23 22:43:00 +02:00
|
|
|
static-ip ? false, # false, or IPv4 address as string
|
2024-03-30 20:49:20 +01:00
|
|
|
default-gateway ? "192.168.1.1",
|
2023-10-21 12:56:02 +02:00
|
|
|
}:
|
2024-06-23 22:43:00 +02:00
|
|
|
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 = [ {
|
2023-10-21 12:56:02 +02:00
|
|
|
address = static-ip;
|
|
|
|
prefixLength = 24;
|
|
|
|
} ];
|
2024-06-23 22:43:00 +02:00
|
|
|
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
|
2023-10-21 12:56:02 +02:00
|
|
|
}
|