summary refs log tree commit diff
path: root/nixos/modules/services/networking/dhcpcd.nix
diff options
context:
space:
mode:
authorBenedikt Hunger <bene@aqtiv.de>2020-01-28 11:51:50 +0100
committerBenedikt Hunger <bene@aqtiv.de>2020-01-28 12:52:19 +0100
commit0767de3dc840352ba6d334d6320ce89ef832410e (patch)
tree0e4921d48072b4374409d497835748a5ee6e79f4 /nixos/modules/services/networking/dhcpcd.nix
parentc8c0bd1fea22cd2b3a585c5891f17b1039d86ace (diff)
downloadnixpkgs-0767de3dc840352ba6d334d6320ce89ef832410e.tar
nixpkgs-0767de3dc840352ba6d334d6320ce89ef832410e.tar.gz
nixpkgs-0767de3dc840352ba6d334d6320ce89ef832410e.tar.bz2
nixpkgs-0767de3dc840352ba6d334d6320ce89ef832410e.tar.lz
nixpkgs-0767de3dc840352ba6d334d6320ce89ef832410e.tar.xz
nixpkgs-0767de3dc840352ba6d334d6320ce89ef832410e.tar.zst
nixpkgs-0767de3dc840352ba6d334d6320ce89ef832410e.zip
nixos/dhcpcd: Add option for dhcpcd waiting behaviour
Diffstat (limited to 'nixos/modules/services/networking/dhcpcd.nix')
-rw-r--r--nixos/modules/services/networking/dhcpcd.nix27
1 files changed, 26 insertions, 1 deletions
diff --git a/nixos/modules/services/networking/dhcpcd.nix b/nixos/modules/services/networking/dhcpcd.nix
index c217ccaa405..b32aef8a50d 100644
--- a/nixos/modules/services/networking/dhcpcd.nix
+++ b/nixos/modules/services/networking/dhcpcd.nix
@@ -59,6 +59,16 @@ let
       # Use the list of allowed interfaces if specified
       ${optionalString (allowInterfaces != null) "allowinterfaces ${toString allowInterfaces}"}
 
+      # Immediately fork to background if specified, otherwise wait for IP address to be assigned
+      ${{
+        background = "background";
+        any = "waitip";
+        ipv4 = "waitip 4";
+        ipv6 = "waitip 6";
+        both = "waitip 4\nwaitip 6";
+        if-carrier-up = "";
+      }.${cfg.wait}}
+
       ${cfg.extraConfig}
     '';
 
@@ -146,6 +156,21 @@ in
       '';
     };
 
+    networking.dhcpcd.wait = mkOption {
+      type = types.enum [ "background" "any" "ipv4" "ipv6" "both" "if-carrier-up" ];
+      default = "any";
+      description = ''
+        This option specifies when the dhcpcd service will fork to background.
+        If set to "background", dhcpcd will fork to background immediately.
+        If set to "ipv4" or "ipv6", dhcpcd will wait for the corresponding IP
+        address to be assigned. If set to "any", dhcpcd will wait for any type
+        (IPv4 or IPv6) to be assigned. If set to "both", dhcpcd will wait for
+        both an IPv4 and an IPv6 address before forking.
+        The option "if-carrier-up" is equivalent to "any" if either ethernet
+        is plugged nor WiFi is powered, and to "background" otherwise.
+      '';
+    };
+
   };
 
 
@@ -177,7 +202,7 @@ in
         serviceConfig =
           { Type = "forking";
             PIDFile = "/run/dhcpcd.pid";
-            ExecStart = "@${dhcpcd}/sbin/dhcpcd dhcpcd -w --quiet ${optionalString cfg.persistent "--persistent"} --config ${dhcpcdConf}";
+            ExecStart = "@${dhcpcd}/sbin/dhcpcd dhcpcd --quiet ${optionalString cfg.persistent "--persistent"} --config ${dhcpcdConf}";
             ExecReload = "${dhcpcd}/sbin/dhcpcd --rebind";
             Restart = "always";
           };