nixbld: factor out network interface names

This commit is contained in:
Sebastien Bourdeauducq 2019-09-18 12:20:03 +08:00
parent 3bd0f2c1e9
commit 9ea3e2e47b
1 changed files with 14 additions and 11 deletions

View File

@ -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;