Use the Nix C API from Rust.
The following will open a shell with dependencies, and install pre-commit for automatic formatting.
$ nix develop
If the rust-analyzer extension fails, make sure the devShell was loaded into VSCode via Nix Env Selector or direnv.