Fetching git submodule dependencies with buildRustPackage

I’m attempting to build uniffi-bindgen-go and buildRustPacakge complains that it doesn’t have all the dependencies download. The project has a git submodule that it uses as a code dependency. This git submodule has its own Cargo.lock with cargo git dependencies which isn’t being fetched.

My derivation looks like so:

let
  pkgs = import <nixpkgs> {};
in
with pkgs;

rustPlatform.buildRustPackage rec {
  pname = "uniffi-bindgen-go";
  version = "v0.2.1+v0.25.0";

  src = fetchFromGitHub {
    owner = "NordSecurity";
    repo = pname;
    rev = "062d054e8ffd9206fc5231d6eba074d3b40cada9";
    sha256 = "sha256-f3KRtJ0Y3HYJm+YoytE3sj+NFSVQHkqkcTgwftX/nN8=";
    fetchSubmodules = true;
  };

  cargoDeps = rustPlatform.importCargoLock {
    lockFile = "${src}/3rd-party/uniffi-rs/Cargo.lock";
    outputHashes = {
      "uniffi-0.25.0" = "";
    };
  };

  cargoSha256 = "sha256-RByHAg5WjUflAoCIZ3m1eB3rYsCVwHEZ8cIxaZqf40c=";
}

Seems like the Cargo.lock file in the git submodule isn’t being recognized and I just get the cargoSha256 before the cargoDeps are downloaded. When I try building I get an error like so:

   Compiling indexmap v1.9.3
   Compiling mime_guess v2.0.4
thread 'main' panicked at cargo-auditable/src/collect_audit_data.rs:77:9:
cargo metadata failure:     Updating git repository `https://github.com/mozilla/uniffi-rs.git`
error: failed to get `uniffi` as a dependency of package `uniffi-fixture-coverall-upstream-compatibility v0.22.0 (/build/source/3rd-party/uniffi-rs/fixtures/coverall-upstream-compatibility)`

Caused by:
  failed to load source for dependency `uniffi`

Caused by:
  Unable to update https://github.com/mozilla/uniffi-rs.git?tag=v0.25.0#a0fb6443

Caused by:
  failed to create directory `/homeless-shelter/.cargo/git/db/uniffi-rs-6f89edd2a1ffa4bd`

Caused by:
  Permission denied (os error 13)

note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
error: could not compile `uniffi-fixture-ext-types-external-crate` (lib)
warning: build failed, waiting for other jobs to finish...
error: builder for '/nix/store/5q885cy8zkz7cy9bm67xk3vlkbhp9jrf-uniffi-bindgen-go-v0.2.1+v0.25.0.drv' failed with exit code 101;
       last 10 log lines:
       >
       > Caused by:
       >   failed to create directory `/homeless-shelter/.cargo/git/db/uniffi-rs-6f89edd2a1ffa4bd`
       >
       > Caused by:
       >   Permission denied (os error 13)
       >
       > note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
       > error: could not compile `uniffi-fixture-ext-types-external-crate` (lib)
       > warning: build failed, waiting for other jobs to finish...

I’ve been reading the documentation and it doesn’t really mention a case where there might be multiple Cargo.lock files for a given project. Any pointers would be greatly appreciated!

Hm, I definitely wouldn’t expect you to be using that Cargo.lock, rather than the one for the package you’re building.

Yeah totally possible that I may have it wrong but the build was failing because of a dependency in the submodule. My assumption was that I needed to also use that Cargo.lock.

Or maybe I need to specify the dependency manually? Not sure :frowning: