From 86c0f8c549c2ad728e06f8bc11d805fe760e7df8 Mon Sep 17 00:00:00 2001 From: "William A. Kennington III" Date: Wed, 16 Jul 2014 17:29:50 -0500 Subject: [PATCH] Refactor nixos files relying on the old ipAddress / prefixLength / subnetMask attributes --- nixos/doc/manual/configuration/ipv4-config.xml | 5 +---- nixos/lib/build-vms.nix | 11 ++++++----- nixos/modules/programs/virtualbox.nix | 2 +- nixos/modules/tasks/network-interfaces.nix | 8 ++++---- nixos/tests/bittorrent.nix | 6 +++--- nixos/tests/nat.nix | 2 +- 6 files changed, 16 insertions(+), 18 deletions(-) diff --git a/nixos/doc/manual/configuration/ipv4-config.xml b/nixos/doc/manual/configuration/ipv4-config.xml index e2c51518349d..053501b1736d 100644 --- a/nixos/doc/manual/configuration/ipv4-config.xml +++ b/nixos/doc/manual/configuration/ipv4-config.xml @@ -12,12 +12,9 @@ interfaces. However, you can configure an interface manually as follows: -networking.interfaces.eth0 = { ipAddress = "192.168.1.2"; prefixLength = 24; }; +networking.interfaces.eth0.ip4 = [ { address = "192.168.1.2"; prefixLength = 24; } ]; -(The network prefix can also be specified using the option -subnetMask, -e.g. "255.255.255.0", but this is deprecated.) Typically you’ll also want to set a default gateway and set of name servers: diff --git a/nixos/lib/build-vms.nix b/nixos/lib/build-vms.nix index 498c0a377836..ba1895554096 100644 --- a/nixos/lib/build-vms.nix +++ b/nixos/lib/build-vms.nix @@ -48,10 +48,11 @@ rec { let interfacesNumbered = zipTwoLists config.virtualisation.vlans (range 1 255); interfaces = flip map interfacesNumbered ({ first, second }: - nameValuePair "eth${toString second}" - { ipAddress = "192.168.${toString first}.${toString m.second}"; - subnetMask = "255.255.255.0"; - }); + nameValuePair "eth${toString second}" { ip4 = + [ { address = "192.168.${toString first}.${toString m.second}"; + prefixLength = 24; + } ]; + } in { key = "ip-address"; config = @@ -60,7 +61,7 @@ rec { networking.interfaces = listToAttrs interfaces; networking.primaryIPAddress = - optionalString (interfaces != []) (head interfaces).value.ipAddress; + optionalString (interfaces != []) (head (head interfaces).value.ip4).address; # Put the IP addresses of all VMs in this machine's # /etc/hosts file. If a machine has multiple diff --git a/nixos/modules/programs/virtualbox.nix b/nixos/modules/programs/virtualbox.nix index e2dd76219eb0..fec1a7b61f32 100644 --- a/nixos/modules/programs/virtualbox.nix +++ b/nixos/modules/programs/virtualbox.nix @@ -44,5 +44,5 @@ let virtualbox = config.boot.kernelPackages.virtualbox; in ''; }; - networking.interfaces.vboxnet0 = { ipAddress = "192.168.56.1"; prefixLength = 24; }; + networking.interfaces.vboxnet0.ip4 = [ { address = "192.168.56.1"; prefixLength = 24; } ]; } diff --git a/nixos/modules/tasks/network-interfaces.nix b/nixos/modules/tasks/network-interfaces.nix index e8c770d077c9..054784502eb2 100644 --- a/nixos/modules/tasks/network-interfaces.nix +++ b/nixos/modules/tasks/network-interfaces.nix @@ -254,10 +254,10 @@ in networking.interfaces = mkOption { default = {}; example = - { eth0 = { - ipAddress = "131.211.84.78"; - subnetMask = "255.255.255.128"; - }; + { eth0.ip4 = [ { + address = "131.211.84.78"; + prefixLength = 25; + } ]; }; description = '' The configuration for each network interface. If diff --git a/nixos/tests/bittorrent.nix b/nixos/tests/bittorrent.nix index 002e012f65f0..7eb9c215ee1c 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=${nodes.router.config.networking.interfaces.eth2.ipAddress}/24 + listening_ip=${(head nodes.router.config.networking.interfaces.eth2.ip4).address}/24 allow 1024-65535 192.168.2.0/24 1024-65535 ''; @@ -53,7 +53,7 @@ in { environment.systemPackages = [ pkgs.transmission ]; virtualisation.vlans = [ 2 ]; networking.defaultGateway = - nodes.router.config.networking.interfaces.eth2.ipAddress; + (head nodes.router.config.networking.interfaces.eth2.ip4).address; networking.firewall.enable = false; }; @@ -81,7 +81,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 -t http://${nodes.tracker.config.networking.interfaces.eth1.ipAddress}:6969/announce -o /tmp/test.torrent"); + $tracker->succeed("transmission-create /tmp/data/test.tar.bz2 -t http://${(head nodes.tracker.config.networking.interfaces.eth1.ip4).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/nat.nix b/nixos/tests/nat.nix index 5fdcc0e97ca9..5a57cce6b678 100644 --- a/nixos/tests/nat.nix +++ b/nixos/tests/nat.nix @@ -13,7 +13,7 @@ import ./make-test.nix { { virtualisation.vlans = [ 1 ]; networking.firewall.allowPing = true; networking.defaultGateway = - nodes.router.config.networking.interfaces.eth2.ipAddress; + (head nodes.router.config.networking.interfaces.eth2.ip4).address; }; router =