Help packaging sss-cli

Hi, I’m trying to package sss-cli. It is a rust project.

When I tried to package this, I first got this error:

error: the lock file /build/source/Cargo.lock needs to be updated but --frozen was passed to prevent this

I found a github issue on nixpkgs which suggested i patch the Cargo.lock file - which i did (despite the fact that i find this a little bit weird, isn’t the purpose of a lock file to build a package reproducably with the exact same dependencies? but that’s just a sidenote)

Anyway, now I have the problem that the cargoHash is not matching: (since i changed the Cargo.lock file with a patch), but i can’t figure out the new one. The error message tells me I should leave the hash empty, run the build and paste the hash, however, when i do that’ I’ll get the same error again. Here is my nix code:

{ lib
, rustPlatform
, fetchFromGitHub
}:

rustPlatform.buildRustPackage rec {
  pname = "sss-cli";
  version = "0.1.1";

  src = fetchFromGitHub {
    owner = "dsprenkels";
    repo = "sss-cli";
    rev = "v${version}";
    hash = "sha256-9Wht+t48SsWpj1z2yY6P7G+h9StmuqfMdODtyPffhak=";
  };

  patches = [ ./update-cargo-lock.patch ];

  cargoHash = "sha256-L06Rpu16na/FL970/Axs1mcQb+OS65yZUW6cEH8FMSs=";

}

And here is the error it produces:

ERROR: cargoHash or cargoSha256 is out of date

Cargo.lock is not the same in /build/sss-cli-0.1.1-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=”;

(following this steps gives me the hash sha256-L06Rpu16na/FL970/Axs1mcQb+OS65yZUW6cEH8FMSs=, which leads to the above error message)

I encountered a similar problem to another package but in my case, it was an error on my part. I copied the Cargo.lock from master branch instead of the rev that I was aiming for.