Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rust: cannot determine cargoSha256 #107070

Open
nrdxp opened this issue Dec 16, 2020 · 5 comments · May be fixed by #194475 or #179392
Open

rust: cannot determine cargoSha256 #107070

nrdxp opened this issue Dec 16, 2020 · 5 comments · May be fixed by #194475 or #179392
Labels
0.kind: bug Something is broken 6.topic: rust

Comments

@nrdxp
Copy link

nrdxp commented Dec 16, 2020

Describe the bug
I am currently on the latest stable relese 20.09. Used to be able to pull the correct cargoSha256 from a failed build. After recently trying to override rnix-lsp to the latest git commit, when the build fails, there is no correct cargoSha256 value to paste into the overlay. All it says is:

ERROR: cargoSha256 is out of date

Cargo.lock is not the same in rnix-lsp-0.1.0-vendor.tar.gz

To fix the issue:
1. Use "0000000000000000000000000000000000000000000000000000" as the cargoSha256 value
2. Build the derivation and wait it to fail with a hash mismatch
3. Copy the 'got: sha256:' value back into the cargoSha256 field

However, after reviewing the entire failed build log, there is no longer a line containing the proper hash as their used to be. Even if I follow the instructions above and replace the full hash with 0's, still there is no proper hash in the build log.

To Reproduce
Steps to reproduce the behavior:
Use this overlay in a NixOS 20.09 configuration:

final: prev: {
  rnix-lsp = prev.rnix-lsp.overrideAttrs (o: {

    src = prev.fetchFromGitHub {
      owner = "nix-community";
      repo = "rnix-lsp";
      rev = "23a07432e98a9a34812c4e6bde5ff40a73f290c1";
      hash = "sha256-G8Tn703lTxUzgmQVNm/v1e40QQrGhymBkuzydM/xrho=";
    };

    cargoSha256 = "0000000000000000000000000000000000000000000000000000";

  });
}

Attempt to build rnix-lsp, and review the build log.
Notice how there is no cargoSha256 to be found anywhere in the log.

I have also attached the build log so you can skip the above steps and see for yourself that the hash is nowhere in the log.
log.gz

Expected behavior
On 20.03, it was quite simple to simply pull the proper hash from the failed build log and copy and paste it into the overlay for rust packages.

Notify maintainers
@andir

@nrdxp nrdxp added the 0.kind: bug Something is broken label Dec 16, 2020
@nrdxp nrdxp changed the title Cannot determine cargoSha256 rust: cannot determine cargoSha256 Dec 16, 2020
@nrdxp
Copy link
Author

nrdxp commented Mar 9, 2021

@pikpikpikpik-123, this actually doesn't work. During a build, its still referencing the old version somewhere that I can't seem to override. Following the threads advice the following overlay should work, but doesn't:

final: prev:
let
  pname = "pijul";
  version = "1.0.0-alpha.48";
  name = "${pname}-${version}";

  src = prev.fetchCrate {
    inherit version pname;
    sha256 = "sha256-L9LoyZ3wrEYJq/W8bL7RfGTc+IIlGdHvlUJyW4wpXyc=";
  };
in
{
  pijul = prev.pijul.overrideAttrs (drv: {
    inherit src version;

    cargoDeps = drv.cargoDeps.overrideAttrs (prev.lib.const {
      inherit src;
      name = "${name}-vendor.tar.gz";
      outputHash = "sha256-PmlZFT+E/NGDq0EneImwoZr7qyp+ptlxH/dabGeZDjQ=";
    });
  });
}

It fails with the following:

error: --- Error ----------------------------------------------------------------- nix
builder for '/nix/store/g82pqh35r3wblfy9pw59qlxddfwiz2qm-pijul-1.0.0-alpha.48.drv' failed with exit code 1; last 7 log lines:
  unpacking sources
  unpacking source archive /nix/store/5px1np78xvckbj7yp5a4zvmjvarl983g-pijul-1.0.0-alpha.48.tar.gz
  source root is pijul-1.0.0-alpha.48.tar.gz
  unpacking source archive /nix/store/41a7lm0ibji2jgp3fnx8kgg0d1igmqlm-pijul-1.0.0-alpha.48-vendor.tar.gz
  setting SOURCE_DATE_EPOCH to timestamp 1615263615 of file pijul-1.0.0-alpha.48.tar.gz/src/repository/unix_lock.rs
  patching sources
  /nix/store/npdq5pilrfsklvhx0ws44lykc1rl1i66-stdenv-linux/setup: line 81: pushd: ../pijul-0.12.0-vendor.tar.gz/thrussh/: No such file or directory

The last line shows a reference to the previous version 0.12.0 even though the version has been overriden to v1.0.0-alpha.48

@nh2
Copy link
Contributor

nh2 commented Mar 12, 2021

This workaround worked for me: https://discourse.nixos.org/t/is-it-possible-to-override-cargosha256-in-buildrustpackage/4393/4

Example usage in my overlay:

let
  nixpkgs-unstable-for-bupstash-source = super.fetchFromGitHub {
    owner = "NixOS";
    repo = "nixpkgs";
    rev = "29b0d4d0b600f8f5dd0b86e3362a33d4181938f9";
    sha256 = "sha256:10cafssjk6wp7lr82pvqh8z7qiqwxpnh8cswnk1fbbw2pacrqxr1";
  };
  nixpkgs-unstable-for-bupstash = import nixpkgs-unstable-for-bupstash-source {};
in
  # This override incantation is from https://discourse.nixos.org/t/is-it-possible-to-override-cargosha256-in-buildrustpackage/4393/4.
  bupstash_unstable = super.callPackage (nixpkgs-unstable-for-bupstash-source + "/pkgs/tools/backup/bupstash/default.nix") {
    rustPlatform = super.rustPlatform // {
      buildRustPackage = args:
        (super.rustPlatform.buildRustPackage (args // {
          src = self.fetchFromGitHub {
            owner = "andrewchambers";
            repo = "bupstash";
            rev = "b719a11b3f9f3e6f2f2cf077a5d05d3f63166f0f"; # update `version` accordingly if you change this
            sha256 = "0ik8zg0798qk5w07kwgaw79gzppdx09jwjw4snd1ahc6igyhl81f";
          };
          cargoSha256 = "0bliiap4n2nrwf0mh028q0cqr2vhk9k9sjvnsm1cz9swqx6xrn8f";
        })).overrideAttrs (old: {
          patches = (old.patches or []) ++ [
            # TODO Remove once https://github.com/andrewchambers/bupstash/pull/108 is merged and available.
            (self.fetchpatch {
              name = "bupstash-Retry-without-O_NOATIME-when-lacking-permission-for-it.patch";
              url = "https://github.com/nh2/bupstash/commit/119bbca9d36a9cf57a07f0e9710f1b87ed0966f4.patch";
              sha256 = "078r9b13nq55na9p2fray2njb4yi8hnkiama0ffsckclcwjycd8m";
            })
          ];
        });
    };
  };

@stale
Copy link

stale bot commented Sep 10, 2021

I marked this as stale due to inactivity. → More info

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Sep 10, 2021
@doronbehar
Copy link
Contributor

This is still an issue for me!

@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Apr 30, 2022
@rgrunbla
Copy link
Contributor

rgrunbla commented May 8, 2022

A small comment regarding people encountering this message and just wanting to rebuild a package in an overlay: embedding the whole package definition (e.g. mypackage = pkgs.rustPlatform.buildRustPackage { … } instead of mypackage = super.mypackage.overrideAttrs (old: rec { … }) and replacing the cargoSha256 = "sha256-..."; with cargoSha256 = ""; to get the new value works. Ugly, but it works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: bug Something is broken 6.topic: rust
Projects
None yet
5 participants