summary refs log tree commit diff
path: root/nixos/modules/tasks
diff options
context:
space:
mode:
authorLinus Heckemann <git@sphalerite.org>2019-10-07 11:29:04 +0200
committerGitHub <noreply@github.com>2019-10-07 11:29:04 +0200
commit0b754fbe542a8455d707516188cb3471663b629e (patch)
tree71154cf737e235ffa0974c0cecfc7595a843c82e /nixos/modules/tasks
parentda089d7d401f99e1c6ccaf5c017878d33260b4e0 (diff)
parent68b42a84fdd167e358ec9f76c40ff3907d0c3c2e (diff)
downloadnixpkgs-0b754fbe542a8455d707516188cb3471663b629e.tar
nixpkgs-0b754fbe542a8455d707516188cb3471663b629e.tar.gz
nixpkgs-0b754fbe542a8455d707516188cb3471663b629e.tar.bz2
nixpkgs-0b754fbe542a8455d707516188cb3471663b629e.tar.lz
nixpkgs-0b754fbe542a8455d707516188cb3471663b629e.tar.xz
nixpkgs-0b754fbe542a8455d707516188cb3471663b629e.tar.zst
nixpkgs-0b754fbe542a8455d707516188cb3471663b629e.zip
Merge pull request #69302 from mayflower/networkd-disallow-dhcp
networkd: disallow useDHCP
Diffstat (limited to 'nixos/modules/tasks')
-rw-r--r--nixos/modules/tasks/network-interfaces-systemd.nix12
-rw-r--r--nixos/modules/tasks/network-interfaces.nix5
2 files changed, 13 insertions, 4 deletions
diff --git a/nixos/modules/tasks/network-interfaces-systemd.nix b/nixos/modules/tasks/network-interfaces-systemd.nix
index 7c6604922cf..863072e33dc 100644
--- a/nixos/modules/tasks/network-interfaces-systemd.nix
+++ b/nixos/modules/tasks/network-interfaces-systemd.nix
@@ -38,6 +38,12 @@ in
     } {
       assertion = cfg.defaultGateway6 == null || cfg.defaultGateway6.interface == null;
       message = "networking.defaultGateway6.interface is not supported by networkd.";
+    } {
+      assertion = cfg.useDHCP == false;
+      message = ''
+        networking.useDHCP is not supported by networkd.
+        Please use per interface configuration and set the global option to false.
+      '';
     } ] ++ flip mapAttrsToList cfg.bridges (n: { rstp, ... }: {
       assertion = !rstp;
       message = "networking.bridges.${n}.rstp is not supported by networkd.";
@@ -56,9 +62,7 @@ in
         genericNetwork = override:
           let gateway = optional (cfg.defaultGateway != null) cfg.defaultGateway.address
             ++ optional (cfg.defaultGateway6 != null) cfg.defaultGateway6.address;
-          in {
-            DHCP = override (dhcpStr cfg.useDHCP);
-          } // optionalAttrs (gateway != [ ]) {
+          in optionalAttrs (gateway != [ ]) {
             routes = override [
               {
                 routeConfig = {
@@ -97,7 +101,7 @@ in
         networks."40-${i.name}" = mkMerge [ (genericNetwork mkDefault) {
           name = mkDefault i.name;
           DHCP = mkForce (dhcpStr
-            (if i.useDHCP != null then i.useDHCP else cfg.useDHCP && interfaceIps i == [ ]));
+            (if i.useDHCP != null then i.useDHCP else false));
           address = forEach (interfaceIps i)
             (ip: "${ip.address}/${toString ip.prefixLength}");
           networkConfig.IPv6PrivacyExtensions = "kernel";
diff --git a/nixos/modules/tasks/network-interfaces.nix b/nixos/modules/tasks/network-interfaces.nix
index 3038be6dbab..31e2ed1cd1e 100644
--- a/nixos/modules/tasks/network-interfaces.nix
+++ b/nixos/modules/tasks/network-interfaces.nix
@@ -903,6 +903,11 @@ in
         Whether to use DHCP to obtain an IP address and other
         configuration for all network interfaces that are not manually
         configured.
+
+        Using this option is highly discouraged and also incompatible with
+        <option>networking.useNetworkd</option>. Please use
+        <option>networking.interfaces.&lt;name&gt;.useDHCP</option> instead
+        and set this to false.
       '';
     };