From 9ea3e2e47b947be6843ffe1f44092a1e0ee97a98 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Wed, 18 Sep 2019 12:20:03 +0800 Subject: [PATCH] nixbld: factor out network interface names --- nixbld-etc-nixos/configuration.nix | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/nixbld-etc-nixos/configuration.nix b/nixbld-etc-nixos/configuration.nix index 056efa6..c62a0dd 100644 --- a/nixbld-etc-nixos/configuration.nix +++ b/nixbld-etc-nixos/configuration.nix @@ -5,6 +5,9 @@ { config, pkgs, ... }: let + netifWan = "enp0s31f6"; + netifLan = "enp3s0"; + netifWifi = "wlp4s0"; hydraWwwOutputs = "/var/www/hydra-outputs"; in { @@ -31,25 +34,25 @@ in allowedTCPPorts = [ 80 443 631 5901 ]; allowedUDPPorts = [ 53 67 631 ]; }; - networkmanager.unmanaged = [ "interface-name:wlp4s0" "interface-name:enp3s0" ]; - interfaces."enp3s0".ipv4.addresses = [{ + networkmanager.unmanaged = [ "interface-name:${netifLan}" "interface-name:${netifWifi}" ]; + interfaces."${netifLan}".ipv4.addresses = [{ address = "192.168.1.1"; prefixLength = 24; }]; - interfaces."wlp4s0".ipv4.addresses = [{ + interfaces."${netifWifi}".ipv4.addresses = [{ address = "192.168.12.1"; prefixLength = 24; }]; nat = { enable = true; - externalInterface = "enp0s31f6"; - internalInterfaces = ["enp3s0" "wlp4s0"]; + externalInterface = netifWan; + internalInterfaces = [ netifLan netifWifi ]; }; }; services.hostapd = { enable = true; - interface = "wlp4s0"; + interface = netifWifi; hwMode = "g"; ssid = "M-Labs"; wpaPassphrase = (import /etc/nixos/secret/wifi_password.nix); @@ -57,11 +60,11 @@ in services.dnsmasq = { enable = true; extraConfig = '' - interface=enp3s0 - interface=wlp4s0 + interface=${netifLan} + interface=${netifWifi} bind-interfaces - dhcp-range=interface:enp3s0,192.168.1.10,192.168.1.254,24h - dhcp-range=interface:wlp4s0,192.168.12.10,192.168.12.254,24h + dhcp-range=interface:${netifLan},192.168.1.10,192.168.1.254,24h + dhcp-range=interface:${netifWifi},192.168.12.10,192.168.12.254,24h ''; }; @@ -106,7 +109,7 @@ in # Enable CUPS to print documents. services.avahi.enable = true; - services.avahi.interfaces = ["enp3s0"]; + services.avahi.interfaces = [ netifLan ]; services.avahi.publish.enable = true; services.avahi.publish.userServices = true; services.printing.enable = true;