diff --git a/src/action/macos/create_nix_volume.rs b/src/action/macos/create_nix_volume.rs index 442fdf8..e0749aa 100644 --- a/src/action/macos/create_nix_volume.rs +++ b/src/action/macos/create_nix_volume.rs @@ -189,6 +189,29 @@ impl Action for CreateNixVolume { .try_execute() .await .map_err(|e| ActionError::Child(self.create_volume.action_tag(), Box::new(e)))?; + + let mut retry_tokens: usize = 50; + loop { + let mut command = Command::new("/usr/sbin/diskutil"); + command.args(["info", "-plist"]); + command.arg(&self.name); + command.stderr(std::process::Stdio::null()); + command.stdout(std::process::Stdio::null()); + tracing::trace!(%retry_tokens, command = ?command.as_std(), "Checking for Nix Store volume existence"); + let output = command + .output() + .await + .map_err(|e| ActionError::command(&command, e))?; + if output.status.success() { + break; + } else if retry_tokens == 0 { + return Err(ActionError::command_output(&command, output)); + } else { + retry_tokens = retry_tokens.saturating_sub(1); + } + tokio::time::sleep(Duration::from_millis(100)).await; + } + self.create_fstab_entry .try_execute() .await @@ -217,17 +240,19 @@ impl Action for CreateNixVolume { let mut retry_tokens: usize = 50; loop { - tracing::trace!(%retry_tokens, "Checking for Nix Store existence"); let mut command = Command::new("/usr/sbin/diskutil"); command.args(["info", "/nix"]); command.stderr(std::process::Stdio::null()); command.stdout(std::process::Stdio::null()); - let status = command - .status() + tracing::trace!(%retry_tokens, command = ?command.as_std(), "Checking for Nix Store mount path existence"); + let output = command + .output() .await .map_err(|e| ActionError::command(&command, e))?; - if status.success() || retry_tokens == 0 { + if output.status.success() { break; + } else if retry_tokens == 0 { + return Err(ActionError::command_output(&command, output)); } else { retry_tokens = retry_tokens.saturating_sub(1); }