about summary refs log tree commit diff
path: root/nixos/modules/installer/tools
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/installer/tools
parentda089d7d401f99e1c6ccaf5c017878d33260b4e0 (diff)
parent68b42a84fdd167e358ec9f76c40ff3907d0c3c2e (diff)
downloadnixlib-0b754fbe542a8455d707516188cb3471663b629e.tar
nixlib-0b754fbe542a8455d707516188cb3471663b629e.tar.gz
nixlib-0b754fbe542a8455d707516188cb3471663b629e.tar.bz2
nixlib-0b754fbe542a8455d707516188cb3471663b629e.tar.lz
nixlib-0b754fbe542a8455d707516188cb3471663b629e.tar.xz
nixlib-0b754fbe542a8455d707516188cb3471663b629e.tar.zst
nixlib-0b754fbe542a8455d707516188cb3471663b629e.zip
Merge pull request #69302 from mayflower/networkd-disallow-dhcp
networkd: disallow useDHCP
Diffstat (limited to 'nixos/modules/installer/tools')
-rw-r--r--nixos/modules/installer/tools/nixos-generate-config.pl20
-rw-r--r--nixos/modules/installer/tools/tools.nix1
2 files changed, 21 insertions, 0 deletions
diff --git a/nixos/modules/installer/tools/nixos-generate-config.pl b/nixos/modules/installer/tools/nixos-generate-config.pl
index cfdbdaabf5c5..f2ffe61c42cb 100644
--- a/nixos/modules/installer/tools/nixos-generate-config.pl
+++ b/nixos/modules/installer/tools/nixos-generate-config.pl
@@ -563,6 +563,24 @@ $fsAndSwap
 ${\join "", (map { "  $_\n" } (uniq @attrs))}}
 EOF
 
+sub generateNetworkingDhcpConfig {
+    my $config = <<EOF;
+  # The global useDHCP flag is deprecated, therefore explicitly set to false here.
+  # Per-interface useDHCP will be mandatory in the future, so this generated config
+  # replicates the default behaviour.
+  networking.useDHCP = false;
+EOF
+
+    foreach my $path (glob "/sys/class/net/*") {
+        my $dev = basename($path);
+        if ($dev ne "lo") {
+            $config .= "  networking.interfaces.$dev.useDHCP = true;\n";
+        }
+    }
+
+    return $config;
+}
+
 
 if ($showHardwareConfig) {
     print STDOUT $hwConfig;
@@ -606,6 +624,8 @@ EOF
 EOF
         }
 
+        my $networkingDhcpConfig = generateNetworkingDhcpConfig();
+
         write_file($fn, <<EOF);
 @configuration@
 EOF
diff --git a/nixos/modules/installer/tools/tools.nix b/nixos/modules/installer/tools/tools.nix
index 05add59117d1..329260059598 100644
--- a/nixos/modules/installer/tools/tools.nix
+++ b/nixos/modules/installer/tools/tools.nix
@@ -96,6 +96,7 @@ in
         # networking.hostName = "nixos"; # Define your hostname.
         # networking.wireless.enable = true;  # Enables wireless support via wpa_supplicant.
 
+      $networkingDhcpConfig
         # Configure network proxy if necessary
         # networking.proxy.default = "http://user:password\@proxy:port/";
         # networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain";