It’s pretty straightforward, in src/Opam_pkg_meta.ml there are two relatively small functions which collect the dependencies:
(* Function to get the crate extension from the opam file *)
let get_crate_ext (opam : OpamFile.OPAM.t) (pkg : OpamPackage.t) =
  match
    OpamStd.String.Map.find_opt crate_extension_name (OpamFile.OPAM.extensions opam)
  with
  | Some { OpamParserTypes.FullPos.pelem; _ } -> parse_metadata pelem pkg
  | None -> None
;;
(* Function to get the crates from the opam file *)
let get_crates (st : [< unlocked > `Lock_write ] switch_state) (opam : OpamFile.OPAM.t) =
  let opam = OpamFormatUpgrade.opam_file opam in
  let nv = OpamFile.OPAM.package opam in
  let st = { st with opams = OpamPackage.Map.add nv opam st.opams } in
  (* Get the dependencies of the package *)
  let depends =
    OpamSwitchState.dependencies
      ~depopts:true
      ~build:true
      ~post:true
      ~installed:true
      st
      (OpamPackage.Set.singleton nv)
    |> OpamPackage.Set.to_list_map (fun x -> x)
    |> List.filter (fun nv1 -> nv1 <> nv)
  in
  (* Filter the dependencies to get the crate dependencies *)
  List.filter_map
    (fun pkg ->
      let opam = OpamSwitchState.opam st pkg in
      get_crate_ext opam pkg)
    depends
;;
It’s not installing Rust what’s the main problem. Rust staticlib needs to be “personalized” to each Opam package being built (as long as that package builds some binaries involving Rust dependencies ofc). And project being built can either be built by Opam when you install some dependency into a switch, or it could be your local project where you do your development, by running dune build for example.
Basically I do what’s suggested by AltGr above, delay building of Rust, let Opam manage the Opam dependencies, encode required Rust dependencies in Opam metadata, OCaml libraries relying on external definitions compile without linking and that allows to delay the building of Rust bits till the linking phase. When Opam package requires binaries, it has to set up Cargo workspace and use rust-staticlib-gen to somewhat automate the boilerplate.
I use Dune virtual library to somewhat protect the users from scary looking linker errors due to missing Rust bits. That virtual library is implemented by the generated Rust staticlib. Maybe Dune could introduce a notion of virtual library implementation provider - some tool that dune will call in each project being built to produce rules needed to build the implementation of a virtual library  Maybe this could be useful for some other purposes. Funny aspect is that I build Cargo from source dir as I got quite tired to fight against Dune sandboxing. Also promote rules that bring different staticlib Cargo assets back to source dir are very useful for running
 Maybe this could be useful for some other purposes. Funny aspect is that I build Cargo from source dir as I got quite tired to fight against Dune sandboxing. Also promote rules that bring different staticlib Cargo assets back to source dir are very useful for running cargo build there (which Rust-capable IDEs do anyway), it makes development of Rust bits quite comfortable as Cargo can find all it needs. I see how this approach might be considered controversial though.