{ config, pkgs, lib, ... }: with lib; let cfg = config.numbus.networking; in { options.numbus.networking = { ipAddress = mkOption { description = "The IP address that this server will use"; type = types.str; example = "192.168.1.100"; }; interface = mkOption { description = "The interface that this server will use to connect to the network"; type = types.str; example = "enp1s0"; }; routerIpAddress = mkOption { description = "The IP address of the router of your network"; type = types.str; example = "192.168.1.1"; }; networkSubnet = mkOption { description = "The subnet of your network"; type = types.str; default = ""; example = "192.168.1.0/24"; }; dnsServers = mkOption { description = "The list of DNS servers that this server will use"; type = types.listOf types.str; default = [ "${cfg.ipAddress}" "9.9.9.9" ]; example = [ "${cfg.ipAddress}" "9.9.9.9" ]; }; }; config = { networking.hostName = "numbus-server"; networking.networkmanager.enable = false; # Allow rootless containers to bind to port 53 and up boot.kernel.sysctl."net.ipv4.ip_unprivileged_port_start" = 53; networking.bridges.br0.interfaces = [ "${cfg.interface}" ]; networking.interfaces."${cfg.interface}".useDHCP = false; networking.interfaces.br0.useDHCP = false; networking.nameservers = cfg.dnsServers; networking.interfaces.br0.ipv4.addresses = [{ address = "${cfg.ipAddress}"; prefixLength = 24; }]; networking.defaultGateway = { address = "${cfg.routerIpAddress}"; interface = "br0"; }; }; }