Fixing the polars package (cargo + [patch] + --frozen ?)

Polars is a data frame library for Rust and Python built on top of Apache Arrow.

The package uses PyO3 to implement Python modules in Rust, and maturin (which belongs to the PyO3 project) to build.

It has a broken package in nixpkgs.

I am trying to fix it.

I’m stuck on the following error

🍹 Building a mixed python/rust project
💥 maturin failed
  Caused by: Cargo metadata failed. Does your crate compile with `cargo build`?
  Caused by: `cargo metadata` exited with an error:     Updating git repository `https://github.com/messense/cmake-rs.git`
error: failed to load source for dependency `cmake`

Caused by:
  Unable to update https://github.com/messense/cmake-rs.git?branch=cross-compile#15ab68ba

Caused by:
  failed to clone into: /build/git/db/cmake-rs-1a1c3c7fd02f9517

Caused by:
  attempting to update a git repository, but --frozen was specified

Which seems to be related to this part of Cargo.toml:

[patch.crates-io]
cmake = { git = "https://github.com/messense/cmake-rs.git", branch = "cross-compile" }

A manual cargo build does succeed locally.

Is the error caused by the sandboxing which disallows network access? If so, I see that rustPlatform has features such as fetchCargoTarball and importCargoLock for getting around these sorts of problems, but I do not see anything that could be applied to this particular case.

Or am I coming up against something like this 3-year-old open (and almost completely ignored) nixpkgs issue?

Just for the sake of debugging, I’ve added a patch that removes the problematic [patch] entry from Cargo.toml. The build now fails with

💥 maturin failed
  Caused by: Cargo metadata failed. Does your crate compile with `cargo build`?
  Caused by: `cargo metadata` exited with an error: error: the lock file /build/source/py-polars/Cargo.lock needs to be updated but --frozen was passed to prevent this
If you want to try to generate the lock file without accessing the network, remove the --frozen flag and use --offline instead.

even though the .../py-polars/Cargo.lock file is checked-in in the project repo and I am using rustPlatform.importCargoLock to import it. I would expect the latter to suppress any need to update the lock file.

What could be causing the build to believe that the lock file needs to be updated?