From e239c1e5820bdbb3d94ccc46e2d6756b0d37057d Mon Sep 17 00:00:00 2001 From: rnhmjoj Date: Sun, 3 Dec 2017 05:14:54 +0100 Subject: [PATCH] nixos/tests: rename IP addresses/routes options --- .../virtualisation/virtualbox-host.nix | 2 +- nixos/tests/bittorrent.nix | 6 ++--- nixos/tests/cjdns.nix | 9 ++++--- nixos/tests/containers-bridge.nix | 4 ++-- nixos/tests/containers-extra_veth.nix | 6 ++--- nixos/tests/containers-hosts.nix | 6 ++--- nixos/tests/containers-macvlans.nix | 8 +++---- .../tests/containers-physical_interfaces.nix | 24 +++++++++---------- nixos/tests/containers-reloadable.nix | 2 +- nixos/tests/containers-restart_networking.nix | 14 +++++------ nixos/tests/ferm.nix | 8 +++---- nixos/tests/initrd-network-ssh/default.nix | 4 +--- nixos/tests/nat.nix | 2 +- nixos/tests/networking.nix | 22 ++++++++--------- nixos/tests/nsd.nix | 22 ++++++++++------- nixos/tests/quagga.nix | 2 +- 16 files changed, 74 insertions(+), 67 deletions(-) diff --git a/nixos/modules/virtualisation/virtualbox-host.nix b/nixos/modules/virtualisation/virtualbox-host.nix index bb0c38bd4eb8..91a46ac852b2 100644 --- a/nixos/modules/virtualisation/virtualbox-host.nix +++ b/nixos/modules/virtualisation/virtualbox-host.nix @@ -124,7 +124,7 @@ in ''; }; - networking.interfaces.vboxnet0.ip4 = [ { address = "192.168.56.1"; prefixLength = 24; } ]; + networking.interfaces.vboxnet0.ipv4.addresses = { address = "192.168.56.1"; prefixLength = 24; }; # Make sure NetworkManager won't assume this interface being up # means we have internet access. networking.networkmanager.unmanaged = ["vboxnet0"]; diff --git a/nixos/tests/bittorrent.nix b/nixos/tests/bittorrent.nix index 3a718a798315..50c98664660a 100644 --- a/nixos/tests/bittorrent.nix +++ b/nixos/tests/bittorrent.nix @@ -16,7 +16,7 @@ let miniupnpdConf = nodes: pkgs.writeText "miniupnpd.conf" '' ext_ifname=eth1 - listening_ip=${(pkgs.lib.head nodes.router.config.networking.interfaces.eth2.ip4).address}/24 + listening_ip=${(pkgs.lib.head nodes.router.config.networking.interfaces.eth2.ipv4.addresses).address}/24 allow 1024-65535 192.168.2.0/24 1024-65535 ''; @@ -56,7 +56,7 @@ in { environment.systemPackages = [ pkgs.transmission ]; virtualisation.vlans = [ 2 ]; networking.defaultGateway = - (pkgs.lib.head nodes.router.config.networking.interfaces.eth2.ip4).address; + (pkgs.lib.head nodes.router.config.networking.interfaces.eth2.ipv4.addresses).address; networking.firewall.enable = false; }; @@ -84,7 +84,7 @@ in # Create the torrent. $tracker->succeed("mkdir /tmp/data"); $tracker->succeed("cp ${file} /tmp/data/test.tar.bz2"); - $tracker->succeed("transmission-create /tmp/data/test.tar.bz2 -p -t http://${(pkgs.lib.head nodes.tracker.config.networking.interfaces.eth1.ip4).address}:6969/announce -o /tmp/test.torrent"); + $tracker->succeed("transmission-create /tmp/data/test.tar.bz2 -p -t http://${(pkgs.lib.head nodes.tracker.config.networking.interfaces.eth1.ipv4.addresses).address}:6969/announce -o /tmp/test.torrent"); $tracker->succeed("chmod 644 /tmp/test.torrent"); # Start the tracker. !!! use a less crappy tracker diff --git a/nixos/tests/cjdns.nix b/nixos/tests/cjdns.nix index 466663799241..4d3b58abc6e5 100644 --- a/nixos/tests/cjdns.nix +++ b/nixos/tests/cjdns.nix @@ -12,7 +12,6 @@ let # the sequence of address assignment less stochastic. networking.useDHCP = false; - networking.interfaces.eth1.prefixLength = 24; # CJDNS output is incompatible with the XML log. systemd.services.cjdns.serviceConfig.StandardOutput = "null"; #networking.firewall.enable = true; @@ -49,7 +48,9 @@ import ./make-test.nix ({ pkgs, ...} : { { imports = [ basicConfig ]; - networking.interfaces.eth1.ipAddress = "192.168.0.2"; + networking.interfaces.eth1.ipv4.addresses = [ + { address = "192.168.0.2"; prefixLength = 24; } + ]; services.cjdns = { UDPInterface = @@ -76,7 +77,9 @@ import ./make-test.nix ({ pkgs, ...} : { CJDNS_ADMIN_PASSWORD=FOOBAR ''; - networking.interfaces.eth1.ipAddress = "192.168.0.1"; + networking.interfaces.eth1.ipv4.addresses = [ + { address = "192.168.0.1"; prefixLength = 24; } + ]; services.cjdns = { authorizedPasswords = [ carolPassword ]; diff --git a/nixos/tests/containers-bridge.nix b/nixos/tests/containers-bridge.nix index b8d4759684cc..dfef46a2ada4 100644 --- a/nixos/tests/containers-bridge.nix +++ b/nixos/tests/containers-bridge.nix @@ -26,8 +26,8 @@ import ./make-test.nix ({ pkgs, ...} : { }; networking.interfaces = { br0 = { - ip4 = [{ address = hostIp; prefixLength = 24; }]; - ip6 = [{ address = hostIp6; prefixLength = 7; }]; + ipv4.addresses = [{ address = hostIp; prefixLength = 24; }]; + ipv6.addresses = [{ address = hostIp6; prefixLength = 7; }]; }; }; diff --git a/nixos/tests/containers-extra_veth.nix b/nixos/tests/containers-extra_veth.nix index 6339c8c558b9..df3f3354b2d9 100644 --- a/nixos/tests/containers-extra_veth.nix +++ b/nixos/tests/containers-extra_veth.nix @@ -21,11 +21,11 @@ import ./make-test.nix ({ pkgs, ...} : { }; networking.interfaces = { br0 = { - ip4 = [{ address = "192.168.0.1"; prefixLength = 24; }]; - ip6 = [{ address = "fc00::1"; prefixLength = 7; }]; + ipv4.addresses = [{ address = "192.168.0.1"; prefixLength = 24; }]; + ipv6.addresses = [{ address = "fc00::1"; prefixLength = 7; }]; }; br1 = { - ip4 = [{ address = "192.168.1.1"; prefixLength = 24; }]; + ipv4.addresses = [{ address = "192.168.1.1"; prefixLength = 24; }]; }; }; diff --git a/nixos/tests/containers-hosts.nix b/nixos/tests/containers-hosts.nix index c7a85f190a5d..df1ef6d14936 100644 --- a/nixos/tests/containers-hosts.nix +++ b/nixos/tests/containers-hosts.nix @@ -13,9 +13,9 @@ import ./make-test.nix ({ pkgs, ...} : { virtualisation.vlans = []; networking.bridges.br0.interfaces = []; - networking.interfaces.br0 = { - ip4 = [ { address = "10.11.0.254"; prefixLength = 24; } ]; - }; + networking.interfaces.br0.ipv4.addresses = [ + { address = "10.11.0.254"; prefixLength = 24; } + ]; # Force /etc/hosts to be the only source for host name resolution environment.etc."nsswitch.conf".text = lib.mkForce '' diff --git a/nixos/tests/containers-macvlans.nix b/nixos/tests/containers-macvlans.nix index 721f98481497..390dc4ad2c29 100644 --- a/nixos/tests/containers-macvlans.nix +++ b/nixos/tests/containers-macvlans.nix @@ -26,9 +26,9 @@ import ./make-test.nix ({ pkgs, ...} : { interface = "eth1"; mode = "bridge"; }; - networking.interfaces.eth1.ip4 = lib.mkForce []; + networking.interfaces.eth1.ipv4.addresses = lib.mkForce []; networking.interfaces.mv-eth1-host = { - ip4 = [ { address = "192.168.1.1"; prefixLength = 24; } ]; + ipv4.addresses = [ { address = "192.168.1.1"; prefixLength = 24; } ]; }; containers.test1 = { @@ -37,7 +37,7 @@ import ./make-test.nix ({ pkgs, ...} : { config = { networking.interfaces.mv-eth1 = { - ip4 = [ { address = containerIp1; prefixLength = 24; } ]; + ipv4.addresses = [ { address = containerIp1; prefixLength = 24; } ]; }; }; }; @@ -48,7 +48,7 @@ import ./make-test.nix ({ pkgs, ...} : { config = { networking.interfaces.mv-eth1 = { - ip4 = [ { address = containerIp2; prefixLength = 24; } ]; + ipv4.addresses = [ { address = containerIp2; prefixLength = 24; } ]; }; }; }; diff --git a/nixos/tests/containers-physical_interfaces.nix b/nixos/tests/containers-physical_interfaces.nix index a3b0b29951bf..bd1228b8e37d 100644 --- a/nixos/tests/containers-physical_interfaces.nix +++ b/nixos/tests/containers-physical_interfaces.nix @@ -16,9 +16,9 @@ import ./make-test.nix ({ pkgs, ...} : { interfaces = [ "eth1" ]; config = { - networking.interfaces.eth1 = { - ip4 = [ { address = "10.10.0.1"; prefixLength = 24; } ]; - }; + networking.interfaces.eth1.ipv4.addresses = [ + { address = "10.10.0.1"; prefixLength = 24; } + ]; networking.firewall.enable = false; }; }; @@ -33,9 +33,9 @@ import ./make-test.nix ({ pkgs, ...} : { config = { networking.bridges.br0.interfaces = [ "eth1" ]; - networking.interfaces.br0 = { - ip4 = [ { address = "10.10.0.2"; prefixLength = 24; } ]; - }; + networking.interfaces.br0.ipv4.addresses = [ + { address = "10.10.0.2"; prefixLength = 24; } + ]; networking.firewall.enable = false; }; }; @@ -54,9 +54,9 @@ import ./make-test.nix ({ pkgs, ...} : { interfaces = [ "eth1" ]; mode = "active-backup"; }; - networking.interfaces.bond0 = { - ip4 = [ { address = "10.10.0.3"; prefixLength = 24; } ]; - }; + networking.interfaces.bond0.ipv4.addresses = [ + { address = "10.10.0.3"; prefixLength = 24; } + ]; networking.firewall.enable = false; }; }; @@ -76,9 +76,9 @@ import ./make-test.nix ({ pkgs, ...} : { mode = "active-backup"; }; networking.bridges.br0.interfaces = [ "bond0" ]; - networking.interfaces.br0 = { - ip4 = [ { address = "10.10.0.4"; prefixLength = 24; } ]; - }; + networking.interfaces.br0.ipv4.addresses = [ + { address = "10.10.0.4"; prefixLength = 24; } + ]; networking.firewall.enable = false; }; }; diff --git a/nixos/tests/containers-reloadable.nix b/nixos/tests/containers-reloadable.nix index b5867c6f6ab1..5fb42f2272b3 100644 --- a/nixos/tests/containers-reloadable.nix +++ b/nixos/tests/containers-reloadable.nix @@ -11,7 +11,7 @@ let # prevent make-test.nix to change IP networking.interfaces = { - eth1.ip4 = lib.mkOverride 0 [ ]; + eth1.ipv4.addresses = lib.mkOverride 0 [ ]; }; }; in { diff --git a/nixos/tests/containers-restart_networking.nix b/nixos/tests/containers-restart_networking.nix index 086d056c51cd..f68c9b07759b 100644 --- a/nixos/tests/containers-restart_networking.nix +++ b/nixos/tests/containers-restart_networking.nix @@ -11,7 +11,7 @@ let config = { networking.firewall.enable = false; networking.firewall.allowPing = true; - networking.interfaces.eth0.ip4 = [ + networking.interfaces.eth0.ipv4.addresses = [ { address = "192.168.1.122"; prefixLength = 24; } ]; }; @@ -33,8 +33,8 @@ in import ./make-test.nix ({ pkgs, lib, ...} : rstp = false; }; networking.interfaces = { - eth1.ip4 = lib.mkOverride 0 [ ]; - br0.ip4 = [{ address = "192.168.1.1"; prefixLength = 24; }]; + eth1.ipv4.addresses = lib.mkOverride 0 [ ]; + br0.ipv4.addresses = [ { address = "192.168.1.1"; prefixLength = 24; } ]; }; }; @@ -44,8 +44,8 @@ in import ./make-test.nix ({ pkgs, lib, ...} : rstp = false; }; networking.interfaces = { - eth1.ip4 = lib.mkOverride 0 [ ]; - br0.ip4 = [{ address = "192.168.1.2"; prefixLength = 24; }]; + eth1.ipv4.addresses = lib.mkOverride 0 [ ]; + br0.ipv4.addresses = [ { address = "192.168.1.2"; prefixLength = 24; } ]; }; }; client_eth1_rstp = { lib, pkgs, ... }: client_base // { @@ -54,8 +54,8 @@ in import ./make-test.nix ({ pkgs, lib, ...} : rstp = true; }; networking.interfaces = { - eth1.ip4 = lib.mkOverride 0 [ ]; - br0.ip4 = [{ address = "192.168.1.2"; prefixLength = 24; }]; + eth1.ipv4.addresses = lib.mkOverride 0 [ ]; + br0.ipv4.addresses = [ { address = "192.168.1.2"; prefixLength = 24; } ]; }; }; }; diff --git a/nixos/tests/ferm.nix b/nixos/tests/ferm.nix index 8f2a8c01eebc..bb7daae118c0 100644 --- a/nixos/tests/ferm.nix +++ b/nixos/tests/ferm.nix @@ -11,8 +11,8 @@ import ./make-test.nix ({ pkgs, ...} : { with pkgs.lib; { networking = { - interfaces.eth1.ip6 = mkOverride 0 [ { address = "fd00::2"; prefixLength = 64; } ]; - interfaces.eth1.ip4 = mkOverride 0 [ { address = "192.168.1.2"; prefixLength = 24; } ]; + interfaces.eth1.ipv6.addresses = mkOverride 0 [ { address = "fd00::2"; prefixLength = 64; } ]; + interfaces.eth1.ipv4.addresses = mkOverride 0 [ { address = "192.168.1.2"; prefixLength = 24; } ]; }; }; server = @@ -20,8 +20,8 @@ import ./make-test.nix ({ pkgs, ...} : { with pkgs.lib; { networking = { - interfaces.eth1.ip6 = mkOverride 0 [ { address = "fd00::1"; prefixLength = 64; } ]; - interfaces.eth1.ip4 = mkOverride 0 [ { address = "192.168.1.1"; prefixLength = 24; } ]; + interfaces.eth1.ipv6.addresses = mkOverride 0 [ { address = "fd00::1"; prefixLength = 64; } ]; + interfaces.eth1.ipv4.addresses = mkOverride 0 [ { address = "192.168.1.1"; prefixLength = 24; } ]; }; services = { diff --git a/nixos/tests/initrd-network-ssh/default.nix b/nixos/tests/initrd-network-ssh/default.nix index 9d476cb1a967..b1f3d147e862 100644 --- a/nixos/tests/initrd-network-ssh/default.nix +++ b/nixos/tests/initrd-network-ssh/default.nix @@ -11,9 +11,7 @@ import ../make-test.nix ({ pkgs, lib, ... }: { config, pkgs, ... }: { boot.kernelParams = [ - "ip=${ - (head config.networking.interfaces.eth1.ip4).address - }:::255.255.255.0::eth1:none" + "ip=${config.networking.primaryIPAddress}:::255.255.255.0::eth1:none" ]; boot.initrd.network = { enable = true; diff --git a/nixos/tests/nat.nix b/nixos/tests/nat.nix index a12b7645bc28..7057158a829b 100644 --- a/nixos/tests/nat.nix +++ b/nixos/tests/nat.nix @@ -35,7 +35,7 @@ import ./make-test.nix ({ pkgs, lib, withFirewall, withConntrackHelpers ? false, { virtualisation.vlans = [ 1 ]; networking.firewall.allowPing = true; networking.defaultGateway = - (pkgs.lib.head nodes.router.config.networking.interfaces.eth2.ip4).address; + (pkgs.lib.head nodes.router.config.networking.interfaces.eth2.ipv4.addresses).address; } (lib.optionalAttrs withConntrackHelpers { networking.firewall.connectionTrackingModules = [ "ftp" ]; diff --git a/nixos/tests/networking.nix b/nixos/tests/networking.nix index 72dbf38ea3a2..18f3e1c548bf 100644 --- a/nixos/tests/networking.nix +++ b/nixos/tests/networking.nix @@ -21,8 +21,8 @@ let firewall.allowedUDPPorts = [ 547 ]; interfaces = mkOverride 0 (listToAttrs (flip map vlanIfs (n: nameValuePair "eth${toString n}" { - ipv4.addresses = [ { address = "192.168.${toString n}.1"; prefixLength = 24;} ]; - ipv6.addresses = [ { address = "fd00:1234:5678:${toString n}::1"; prefixLength = 64;} ]; + ipv4.addresses = [ { address = "192.168.${toString n}.1"; prefixLength = 24; } ]; + ipv6.addresses = [ { address = "fd00:1234:5678:${toString n}::1"; prefixLength = 64; } ]; }))); }; services.dhcpd4 = { @@ -435,13 +435,13 @@ let name = "Virtual"; machine = { networking.interfaces."tap0" = { - ip4 = [ { address = "192.168.1.1"; prefixLength = 24; } ]; - ip6 = [ { address = "2001:1470:fffd:2096::"; prefixLength = 64; } ]; + ipv4.addresses = [ { address = "192.168.1.1"; prefixLength = 24; } ]; + ipv6.addresses = [ { address = "2001:1470:fffd:2096::"; prefixLength = 64; } ]; virtual = true; }; networking.interfaces."tun0" = { - ip4 = [ { address = "192.168.1.2"; prefixLength = 24; } ]; - ip6 = [ { address = "2001:1470:fffd:2097::"; prefixLength = 64; } ]; + ipv4.addresses = [ { address = "192.168.1.2"; prefixLength = 24; } ]; + ipv6.addresses = [ { address = "2001:1470:fffd:2097::"; prefixLength = 64; } ]; virtual = true; }; }; @@ -481,9 +481,9 @@ let boot.kernel.sysctl."net.ipv6.conf.all.forwarding" = true; networking = { useNetworkd = networkd; - interfaces.eth1 = { - ipv6Address = "fd00:1234:5678:1::1"; - ipv6PrefixLength = 64; + interfaces.eth1.ipv6.addresses = singleton { + address = "fd00:1234:5678:1::1"; + prefixLength = 64; }; }; services.radvd = { @@ -509,8 +509,8 @@ let useDHCP = true; interfaces.eth1 = { preferTempAddress = true; - ip4 = mkOverride 0 [ ]; - ip6 = mkOverride 0 [ ]; + ipv4.addresses = mkOverride 0 [ ]; + ipv6.addresses = mkOverride 0 [ ]; }; }; }; diff --git a/nixos/tests/nsd.nix b/nixos/tests/nsd.nix index 0b1082056f6f..ad4d4f822435 100644 --- a/nixos/tests/nsd.nix +++ b/nixos/tests/nsd.nix @@ -15,25 +15,31 @@ in import ./make-test.nix ({ pkgs, ...} : { clientv4 = { lib, nodes, ... }: { imports = [ common ]; networking.nameservers = lib.mkForce [ - nodes.server.config.networking.interfaces.eth1.ipAddress + (lib.head nodes.server.config.networking.interfaces.eth1.ipv4.addresses).address + ]; + networking.interfaces.eth1.ipv4.addresses = [ + { address = "192.168.0.2"; prefixLength = 24; } ]; - networking.interfaces.eth1.ipAddress = "192.168.0.2"; - networking.interfaces.eth1.prefixLength = 24; }; clientv6 = { lib, nodes, ... }: { imports = [ common ]; networking.nameservers = lib.mkForce [ - nodes.server.config.networking.interfaces.eth1.ipv6Address + (lib.head nodes.server.config.networking.interfaces.eth1.ipv6.addresses).address + ]; + networking.interfaces.eth1.ipv4.addresses = [ + { address = "dead:beef::2"; prefixLength = 24; } ]; - networking.interfaces.eth1.ipv6Address = "dead:beef::2"; }; server = { lib, ... }: { imports = [ common ]; - networking.interfaces.eth1.ipAddress = "192.168.0.1"; - networking.interfaces.eth1.prefixLength = 24; - networking.interfaces.eth1.ipv6Address = "dead:beef::1"; + networking.interfaces.eth1.ipv4.addresses = [ + { address = "192.168.0.1"; prefixLength = 24; } + ]; + networking.interfaces.eth1.ipv6.addresses = [ + { address = "dead:beef::1"; prefixLength = 64; } + ]; services.nsd.enable = true; services.nsd.interfaces = lib.mkForce []; services.nsd.zones."example.com.".data = '' diff --git a/nixos/tests/quagga.nix b/nixos/tests/quagga.nix index b9644b4768c0..613180942c41 100644 --- a/nixos/tests/quagga.nix +++ b/nixos/tests/quagga.nix @@ -8,7 +8,7 @@ import ./make-test.nix ({ pkgs, ... }: let - ifAddr = node: iface: (pkgs.lib.head node.config.networking.interfaces.${iface}.ip4).address; + ifAddr = node: iface: (pkgs.lib.head node.config.networking.interfaces.${iface}.ipv4.addresses).address; ospfConf = '' interface eth2