From 89928a8fee998df05d1cd743e23f1fe0d8ed98a8 Mon Sep 17 00:00:00 2001 From: Jack O'Sullivan Date: Wed, 18 May 2022 20:57:26 +0100 Subject: [PATCH] nixos/colony: Hopefully fix estuary attempting to start early --- nixos/boxes/colony.nix | 16 +++++++++++++--- nixos/modules/vms.nix | 2 +- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/nixos/boxes/colony.nix b/nixos/boxes/colony.nix index 07d88ea..3df2648 100644 --- a/nixos/boxes/colony.nix +++ b/nixos/boxes/colony.nix @@ -64,10 +64,20 @@ }; networks."80-base" = networkdAssignment "base" assignments.internal; }; - services."vm@estuary" = rec { - # Bind to the interface, networkd wait-online would deadlock... + + services."vm@estuary" = { + # Depend the interface, networkd wait-online would deadlock... requires = [ "sys-subsystem-net-devices-base.device" ]; - bindsTo = requires; + preStart = '' + count=0 + while ! ${pkgs.iproute2}/bin/ip link show dev base > /dev/null 2>&1; do + count=$((count+1)) + if [ $count -ge 5 ]; then + echo "Timed out waiting for bridge interface" + fi + sleep 0.5 + done + ''; }; }; diff --git a/nixos/modules/vms.nix b/nixos/modules/vms.nix index 02d7a14..60129b6 100644 --- a/nixos/modules/vms.nix +++ b/nixos/modules/vms.nix @@ -30,7 +30,7 @@ let print(f'usage: {sys.argv[0]} ', file=sys.stderr) sys.exit(1) - if not os.path.exists(sys.argv[1]) and 'MAINPID' not in os.environ: + if 'MAINPID' not in os.environ: # Special case: systemd is calling us after QEMU exited on its own sys.exit(0)