Refactor nixos files relying on the old ipAddress / prefixLength / subnetMask attributes
This commit is contained in:
parent
1ff4b83875
commit
86c0f8c549
@ -12,12 +12,9 @@ interfaces. However, you can configure an interface manually as
|
||||
follows:
|
||||
|
||||
<programlisting>
|
||||
networking.interfaces.eth0 = { ipAddress = "192.168.1.2"; prefixLength = 24; };
|
||||
networking.interfaces.eth0.ip4 = [ { address = "192.168.1.2"; prefixLength = 24; } ];
|
||||
</programlisting>
|
||||
|
||||
(The network prefix can also be specified using the option
|
||||
<literal>subnetMask</literal>,
|
||||
e.g. <literal>"255.255.255.0"</literal>, but this is deprecated.)
|
||||
Typically you’ll also want to set a default gateway and set of name
|
||||
servers:
|
||||
|
||||
|
@ -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
|
||||
|
@ -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; } ];
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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 =
|
||||
|
Loading…
Reference in New Issue
Block a user