summary refs log tree commit diff
path: root/nixos/modules/system/boot/initrd-network.nix
diff options
context:
space:
mode:
authorFranz Pletz <fpletz@fnordicwalking.de>2020-02-08 14:55:29 +0100
committerFranz Pletz <fpletz@fnordicwalking.de>2020-02-08 14:57:49 +0100
commit589789997fe882668eae25f1f0578230d8576506 (patch)
tree1a541cfc99a0c7c334cbc58ce645bd8bfd3b1ff5 /nixos/modules/system/boot/initrd-network.nix
parentd25c1a8fdc383b8997f6e7b4e1479875df1f06b2 (diff)
downloadnixpkgs-589789997fe882668eae25f1f0578230d8576506.tar
nixpkgs-589789997fe882668eae25f1f0578230d8576506.tar.gz
nixpkgs-589789997fe882668eae25f1f0578230d8576506.tar.bz2
nixpkgs-589789997fe882668eae25f1f0578230d8576506.tar.lz
nixpkgs-589789997fe882668eae25f1f0578230d8576506.tar.xz
nixpkgs-589789997fe882668eae25f1f0578230d8576506.tar.zst
nixpkgs-589789997fe882668eae25f1f0578230d8576506.zip
nixos/initrd-network: always run postCommands
As outlined in #71447, postCommands should always be run if networking
in initrd is enabled. regardless if the configuration actually
succeeded.
Diffstat (limited to 'nixos/modules/system/boot/initrd-network.nix')
-rw-r--r--nixos/modules/system/boot/initrd-network.nix33
1 files changed, 12 insertions, 21 deletions
diff --git a/nixos/modules/system/boot/initrd-network.nix b/nixos/modules/system/boot/initrd-network.nix
index d36850c2a16..0ab6e626b34 100644
--- a/nixos/modules/system/boot/initrd-network.nix
+++ b/nixos/modules/system/boot/initrd-network.nix
@@ -113,8 +113,7 @@ in
         for o in $(cat /proc/cmdline); do
           case $o in
             ip=*)
-              ipconfig $o && hasNetwork=1 \
-                && ifaces="$ifaces $(echo $o | cut -d: -f6)"
+              ipconfig $o && ifaces="$ifaces $(echo $o | cut -d: -f6)"
               ;;
           esac
         done
@@ -122,28 +121,20 @@ in
 
       # Otherwise, use DHCP.
       + optionalString doDhcp ''
-        if [ -z "$hasNetwork" ]; then
-
-          # Bring up all interfaces.
-          for iface in ${dhcpIfShellExpr}; do
-            echo "bringing up network interface $iface..."
-            ip link set "$iface" up && ifaces="$ifaces $iface"
-          done
+        # Bring up all interfaces.
+        for iface in ${dhcpIfShellExpr}; do
+          echo "bringing up network interface $iface..."
+          ip link set "$iface" up && ifaces="$ifaces $iface"
+        done
 
-          # Acquire DHCP leases.
-          for iface in ${dhcpIfShellExpr}; do
-            echo "acquiring IP address via DHCP on $iface..."
-            udhcpc --quit --now -i $iface -O staticroutes --script ${udhcpcScript} ${udhcpcArgs} && hasNetwork=1
-          done
-        fi
+        # Acquire DHCP leases.
+        for iface in ${dhcpIfShellExpr}; do
+          echo "acquiring IP address via DHCP on $iface..."
+          udhcpc --quit --now -i $iface -O staticroutes --script ${udhcpcScript} ${udhcpcArgs}
+        done
       ''
 
-      + ''
-        if [ -n "$hasNetwork" ]; then
-          echo "networking is up!"
-          ${cfg.postCommands}
-        fi
-      '');
+      + cfg.postCommands);
 
     boot.initrd.postMountCommands = mkIf cfg.flushBeforeStage2 ''
       for iface in $ifaces; do