git.iko.soy/typeable/nixpkgs
on master help sign in
initrd-network: call postCommands only if network is up
commitb4528a696a6ea50b98ac1919fc2da85e325cab41 authorNikolay Amiantov <ab@fmap.me> dateWed 3 Feb 2016, 15:51 (11 years ago) parent20b54bd
1 file changed+9−4
nixos/modules/system/boot/initrd-network.nix+9−4
nixos/modules/system/boot/initrd-network.nix+9−4
@@ -63,9 +63,9 @@ in
6363 copy_bin_and_libs ${pkgs.mkinitcpio-nfs-utils}/bin/ipconfig
6464 '';
6565
66− boot.initrd.preLVMCommands =
66+ boot.initrd.preLVMCommands = mkBefore (
6767 # Search for interface definitions in command line.
68− mkBefore ''
68+ ''
6969 for o in $(cat /proc/cmdline); do
7070 case $o in
7171 ip=*)
@@ -87,11 +87,16 @@ in
8787
8888 # Acquire a DHCP lease.
8989 echo "acquiring IP address via DHCP..."
90− udhcpc --quit --now --script ${udhcpcScript}
90+ udhcpc --quit --now --script ${udhcpcScript} && hasNetwork=1
9191 fi
9292 ''
9393
94− + cfg.postCommands;
94+ + ''
95+ if [ -n "$hasNetwork" ]; then
96+ echo "networking is up!"
97+ ${cfg.postCommands}
98+ fi
99+ '');
95100
96101 };
97102