summary refs log tree commit diff
path: root/nixos/modules/installer/tools/nixos-generate-config.pl
diff options
context:
space:
mode:
authorRobin Gloster <mail@glob.in>2019-09-24 11:41:12 +0200
committerRobin Gloster <mail@glob.in>2019-09-24 11:44:01 +0200
commit5ee383ea8c31cd7c8489c2b076aac9c51f63b55c (patch)
tree8adfc40bc7583bbf0475f8d4949d4806a8945e7a /nixos/modules/installer/tools/nixos-generate-config.pl
parente862dd637350ddd1812a6c1fb5811c6464e74ff5 (diff)
downloadnixpkgs-5ee383ea8c31cd7c8489c2b076aac9c51f63b55c.tar
nixpkgs-5ee383ea8c31cd7c8489c2b076aac9c51f63b55c.tar.gz
nixpkgs-5ee383ea8c31cd7c8489c2b076aac9c51f63b55c.tar.bz2
nixpkgs-5ee383ea8c31cd7c8489c2b076aac9c51f63b55c.tar.lz
nixpkgs-5ee383ea8c31cd7c8489c2b076aac9c51f63b55c.tar.xz
nixpkgs-5ee383ea8c31cd7c8489c2b076aac9c51f63b55c.tar.zst
nixpkgs-5ee383ea8c31cd7c8489c2b076aac9c51f63b55c.zip
nixos-generate-config: add useDHCP per interface
This sets networking.useDHCP to false and for all interfaces found the
per-interface useDHCP to true. This replicates the current default
behaviour and prepares for the switch to networkd.
Diffstat (limited to 'nixos/modules/installer/tools/nixos-generate-config.pl')
-rw-r--r--nixos/modules/installer/tools/nixos-generate-config.pl20
1 files changed, 20 insertions, 0 deletions
diff --git a/nixos/modules/installer/tools/nixos-generate-config.pl b/nixos/modules/installer/tools/nixos-generate-config.pl
index cfdbdaabf5c..f2ffe61c42c 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