summary refs log tree commit diff
path: root/nixos
diff options
context:
space:
mode:
authorWilliam A. Kennington III <william@wkennington.com>2014-08-30 08:00:10 -0700
committerWilliam A. Kennington III <william@wkennington.com>2014-08-30 08:05:00 -0700
commit4d8390be608ed047ef99d96b0a3f58516bad4419 (patch)
treec3a261ae4f95d769b77623518594482f4cfd63c7 /nixos
parent86c0f8c549c2ad728e06f8bc11d805fe760e7df8 (diff)
downloadnixpkgs-4d8390be608ed047ef99d96b0a3f58516bad4419.tar
nixpkgs-4d8390be608ed047ef99d96b0a3f58516bad4419.tar.gz
nixpkgs-4d8390be608ed047ef99d96b0a3f58516bad4419.tar.bz2
nixpkgs-4d8390be608ed047ef99d96b0a3f58516bad4419.tar.lz
nixpkgs-4d8390be608ed047ef99d96b0a3f58516bad4419.tar.xz
nixpkgs-4d8390be608ed047ef99d96b0a3f58516bad4419.tar.zst
nixpkgs-4d8390be608ed047ef99d96b0a3f58516bad4419.zip
nixos/network-interfaces: Support the old ip configuration convention
Diffstat (limited to 'nixos')
-rw-r--r--nixos/modules/services/networking/dhcpcd.nix2
-rw-r--r--nixos/modules/tasks/network-interfaces.nix51
2 files changed, 36 insertions, 17 deletions
diff --git a/nixos/modules/services/networking/dhcpcd.nix b/nixos/modules/services/networking/dhcpcd.nix
index 65b4319b50a..7e0b00a3d7b 100644
--- a/nixos/modules/services/networking/dhcpcd.nix
+++ b/nixos/modules/services/networking/dhcpcd.nix
@@ -11,7 +11,7 @@ let
   # Don't start dhcpcd on explicitly configured interfaces or on
   # interfaces that are part of a bridge, bond or sit device.
   ignoredInterfaces =
-    map (i: i.name) (filter (i: i.ip4 != [ ]) (attrValues config.networking.interfaces))
+    map (i: i.name) (filter (i: i.ip4 != [ ] || i.ipAddress != null) (attrValues config.networking.interfaces))
     ++ mapAttrsToList (i: _: i) config.networking.sits
     ++ concatLists (attrValues (mapAttrs (n: v: v.interfaces) config.networking.bridges))
     ++ concatLists (attrValues (mapAttrs (n: v: v.interfaces) config.networking.bonds))
diff --git a/nixos/modules/tasks/network-interfaces.nix b/nixos/modules/tasks/network-interfaces.nix
index 054784502eb..ac3a55332e4 100644
--- a/nixos/modules/tasks/network-interfaces.nix
+++ b/nixos/modules/tasks/network-interfaces.nix
@@ -68,36 +68,48 @@ let
 
       ipAddress = mkOption {
         default = null;
+        example = "10.0.0.1";
+        type = types.nullOr types.str;
         description = ''
-          Defunct, create an address in the ip4 list instead.
+          IP address of the interface.  Leave empty to configure the
+          interface using DHCP.
         '';
       };
 
       prefixLength = mkOption {
         default = null;
+        example = 24;
+        type = types.nullOr types.int;
         description = ''
-          Defunct, supply the prefix length in the ip4 list instead.
+          Subnet mask of the interface, specified as the number of
+          bits in the prefix (<literal>24</literal>).
         '';
       };
 
       subnetMask = mkOption {
         default = null;
         description = ''
-          Defunct, supply the prefix length in the ip4 list instead.
+          Defunct, supply the prefix length instead.
         '';
       };
 
       ipv6Address = mkOption {
         default = null;
+        example = "2001:1470:fffd:2098::e006";
+        type = types.nullOr types.str;
         description = ''
-          Defunct, create an address in the ip6 list instead.
+          IPv6 address of the interface.  Leave empty to configure the
+          interface using NDP.
         '';
       };
 
       ipv6prefixLength = mkOption {
-        default = null;
+        default = 64;
+        example = 64;
+        type = types.int;
         description = ''
-          Defunct, supply the prefix length in the ip6 list instead.
+          Subnet mask of the interface, specified as the number of
+          bits in the prefix (<literal>64</literal>).
         '';
       };
 
@@ -470,12 +482,8 @@ in
 
     assertions =
       flip map interfaces (i: {
-        assertion = i.ipAddress == null && i.prefixLength == null && i.subnetMask == null;
-        message = "The networking.interfaces.${i.name}.ipAddress option is defunct. Use networking.ip4 instead.";
-      })
-      ++ flip map interfaces (i: {
-        assertion = i.ipv6Address == null && i.ipv6prefixLength == null;
-        message = "The networking.interfaces.${i.name}.ipv6Address option is defunct. Use networking.ip6 instead.";
+        assertion = i.subnetMask == null;
+        message = "The networking.interfaces.${i.name}.subnetMask option is defunct. Use prefixLength instead.";
       });
 
     boot.kernelModules = [ ]
@@ -574,7 +582,18 @@ in
         # network device, so it only gets started after the interface
         # has appeared, and it's stopped when the interface
         # disappears.
-        configureInterface = i: nameValuePair "${i.name}-cfg"
+        configureInterface = i:
+          let
+            ips = i.ip4 ++ optionals cfg.enableIPv6 i.ip6
+              ++ optional (i.ipAddress != null) {
+                ipAddress = i.ipAddress;
+                prefixLength = i.prefixLength;
+              } ++ optional (cfg.enableIPv6 && i.ipv6Address != null) {
+                ipAddress = i.ipv6Address;
+                prefixLength = i.ipv6PrefixLength;
+              };
+          in
+          nameValuePair "${i.name}-cfg"
           { description = "Configuration of ${i.name}";
             wantedBy = [ "network-interfaces.target" ];
             bindsTo = [ "sys-subsystem-net-devices-${i.name}.device" ];
@@ -606,7 +625,7 @@ in
                   # useful when the Nix store is accessed via this
                   # interface (e.g. in a QEMU VM test).
                 ''
-              + flip concatMapStrings (i.ip4 ++ optionals cfg.enableIPv6 i.ip6) (ip:
+              + flip concatMapStrings (ips) (ip:
                 let
                   address = "${ip.address}/${toString ip.prefixLength}";
                 in
@@ -622,7 +641,7 @@ in
                     fi
                   fi
                 '')
-              + optionalString (i.ip4 != [ ] || (cfg.enableIPv6 && i.ip6 != [ ]))
+              + optionalString (ips != [ ])
                 ''
                   if [ restart_network_setup = true ]; then
                     # Ensure that the default gateway remains set.
@@ -643,7 +662,7 @@ in
               ''
                 echo "releasing configured ip's..."
               ''
-              + flip concatMapStrings (i.ip4 ++ optionals cfg.enableIPv6 i.ip6) (ip:
+              + flip concatMapStrings (ips) (ip:
                 let
                   address = "${ip.address}/${toString ip.prefixLength}";
                 in