buildRustPackage just keeps saying Cargo.lock is wrong and to update hashes (solved)

Hey thanks for looking :slight_smile:

I’m trying to make a derivation for the boon cli from GitHub - santhosh-tekuri/boon: JSONSchema (draft 2020-12, draft 2019-09, draft-7, draft-6, draft-4) Validation in Rust

I have this from following the docs and looking at other existing derivations for related things.

{ stdenv, lib, rustPlatform, fetchFromGitHub }:
rustPlatform.buildRustPackage rec {
  pname = "boon-cli";
  version = "0.6.0";

  src = fetchFromGitHub {
    owner = "santhosh-tekuri";
    repo = "boon";
    rev = "v${version}";
    sha256 = "sha256-evXxahueOlFxkWnJbB7kxhvD/WMTVEFEiKvdEl5MWbU=";
  };

  cargoRoot = "cli";
  cargoHash = "sha256-oxasA7UoyQGCLnh+cm1otlokh9zifOfPYYTq5dfUwQ4=";

  meta = with stdenv.lib; {
    description = "JSONSchema (draft 2020-12, draft 2019-09, draft-7, draft-6, draft-4) Validation in Rust";
    homepage = "https://github.com/santhosh-tekuri/boon";
    license = lib.licenses.mit;
  };
}

However when I run it i get the following error. This is after having done the steps to fix it. I tried doing the steps for all the hashes just in case one was being weird but nothing is working.

error: builder for '/nix/store/7m5i7d0h31vpal30ckqg1wz709cd1jnj-boon-cli-0.6.0.drv' failed with exit code 1;
       last 25 log lines:
       > 584c1019,1025
       > < version = "0.52.5"
       > ---
       > > version = "0.48.5"
       > > source = "registry+https://github.com/rust-lang/crates.io-index"
       > > checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538"
       > >
       > > [[package]]
       > > name = "windows_x86_64_msvc"
       > > version = "0.52.0"
       > 586c1027
       > < checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0"
       > ---
       > > checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04"
       >
       > ERROR: cargoHash or cargoSha256 is out of date
       >
       > Cargo.lock is not the same in /build/boon-cli-0.6.0-vendor.tar.gz
       >
       > To fix the issue:
       > 1. Set cargoHash/cargoSha256 to an empty string: `cargoHash = "";`
       > 2. Build the derivation and wait for it to fail with a hash mismatch
       > 3. Copy the "got: sha256-..." value back into the cargoHash field
       >    You should have: cargoHash = "sha256-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX=";
       >
       For full logs, run 'nix log /nix/store/7m5i7d0h31vpal30ckqg1wz709cd1jnj-boon-cli-0.6.0.drv'.

I have a suspicion that the slightly odd set up with a cli Cargo.toml/lock referencing the library via relative path might be related, but i couldn’t see for certain that it is.

Any help very much appreciated thank you

I think I might have found why it’s not working! I’ve resorted to forking the repository and moving things around so the cli is in the root for now. Couldn’t get any tips from the issue to work without doing that

What steps? And what was fixed?

You can set sourceRoot instead, this seems to build (thought I would not be able to explain why):

{
  stdenv,
  lib,
  rustPlatform,
  fetchFromGitHub,
}:
rustPlatform.buildRustPackage rec {
  pname = "boon-cli";
  version = "0.6.0";

  src = fetchFromGitHub {
    owner = "santhosh-tekuri";
    repo = "boon";
    rev = "v${version}";
    sha256 = "sha256-evXxahueOlFxkWnJbB7kxhvD/WMTVEFEiKvdEl5MWbU=";
  };

  sourceRoot = "${src.name}/cli";
  cargoHash = "sha256-Gk48H8BmuLFD99FNNZizxSiOVqSKdhYY9ihgtD7lnng=";

  meta = {
    description = "JSONSchema (draft 2020-12, draft 2019-09, draft-7, draft-6, draft-4) Validation in Rust";
    homepage = "https://github.com/santhosh-tekuri/boon";
    license = lib.licenses.mit;
  };
}

What steps? And what was fixed?

I mean the steps that the error message suggests on how to fix it.

You can set sourceRoot instead

Thank you @ghpzin that’s really helpful! :smiley: I can’t believe I didn’t try that. I thought that would cause it to not be able to find the parent source.