about summary refs log tree commit diff
path: root/nixos
diff options
context:
space:
mode:
authorNikolay Amiantov <ab@fmap.me>2016-02-03 15:51:28 +0300
committerNikolay Amiantov <ab@fmap.me>2016-02-03 16:35:21 +0300
commitb4528a696a6ea50b98ac1919fc2da85e325cab41 (patch)
tree396155031b751736b7dba4cacc1713f2a1bc28e9 /nixos
parent20b54bd9899e28c157086847f666d4ebec0f3c36 (diff)
downloadnixlib-b4528a696a6ea50b98ac1919fc2da85e325cab41.tar
nixlib-b4528a696a6ea50b98ac1919fc2da85e325cab41.tar.gz
nixlib-b4528a696a6ea50b98ac1919fc2da85e325cab41.tar.bz2
nixlib-b4528a696a6ea50b98ac1919fc2da85e325cab41.tar.lz
nixlib-b4528a696a6ea50b98ac1919fc2da85e325cab41.tar.xz
nixlib-b4528a696a6ea50b98ac1919fc2da85e325cab41.tar.zst
nixlib-b4528a696a6ea50b98ac1919fc2da85e325cab41.zip
initrd-network: call postCommands only if network is up
Diffstat (limited to 'nixos')
-rw-r--r--nixos/modules/system/boot/initrd-network.nix13
1 files changed, 9 insertions, 4 deletions
diff --git a/nixos/modules/system/boot/initrd-network.nix b/nixos/modules/system/boot/initrd-network.nix
index 8ccf56ff6e0d..6e226c190609 100644
--- a/nixos/modules/system/boot/initrd-network.nix
+++ b/nixos/modules/system/boot/initrd-network.nix
@@ -63,9 +63,9 @@ in
       copy_bin_and_libs ${pkgs.mkinitcpio-nfs-utils}/bin/ipconfig
     '';
 
-    boot.initrd.preLVMCommands =
+    boot.initrd.preLVMCommands = mkBefore (
       # Search for interface definitions in command line.
-      mkBefore ''
+      ''
         for o in $(cat /proc/cmdline); do
           case $o in
             ip=*)
@@ -87,11 +87,16 @@ in
 
           # Acquire a DHCP lease.
           echo "acquiring IP address via DHCP..."
-          udhcpc --quit --now --script ${udhcpcScript}
+          udhcpc --quit --now --script ${udhcpcScript} && hasNetwork=1
         fi
       ''
 
-      + cfg.postCommands;
+      + ''
+        if [ -n "$hasNetwork" ]; then
+          echo "networking is up!"
+          ${cfg.postCommands}
+        fi
+      '');
 
   };