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

Allow empty hashes #3544

Closed
wants to merge 1 commit into from
Closed

Conversation

matthewbauer
Copy link
Member

This allows hash="" so that it can be used for debugging purposes. For
instance, this gives you an error message like:

warning: found empty hash, assuming you wanted 'sha256:0000000000000000000000000000000000000000000000000000'
hash mismatch in fixed-output derivation '/nix/store/jx3gikmipizpk181cgfa1l4wwcamy6p0-nixpkgs':
wanted: sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=
got: sha256-Wm7FDDnzNteClYOn+LRCtPNcK9wjEtpj+k9IIfygD7o=

This allows hash="" so that it can be used for debugging purposes. For
instance, this gives you an error message like:

warning: found empty hash, assuming you wanted 'sha256:0000000000000000000000000000000000000000000000000000'
hash mismatch in fixed-output derivation '/nix/store/jx3gikmipizpk181cgfa1l4wwcamy6p0-nixpkgs':
  wanted: sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=
  got:    sha256-Wm7FDDnzNteClYOn+LRCtPNcK9wjEtpj+k9IIfygD7o=
@NorfairKing
Copy link

@matthewbauer I think the only argument against this is that 0 may be a valid hash (I don't think it's likely, but still).
Could we instead just always print the gotten hash, even if the wanted hash was of incorrect length?

That being said, I think this is already an improvement and my suggestion is about a case that practically should not happen. (Unless the hash on an empty string is 0).

@edolstra
Copy link
Member

I think we have to be very careful about this not having unintended side effects. It seems safer to handle this at a higher level than in the Hash type (which is used all over the place).

@edolstra
Copy link
Member

An example of "higher level" would be fetchurl, which could set a dummy hash if none is specified, or prim_derivationStrict (but it would have to be careful not to turn normal derivations into fixed-output derivations with a dummy hash).

@matthewbauer
Copy link
Member Author

Right - a more explicit try / catch here would be better.

@edolstra
Copy link
Member

edolstra commented Jun 2, 2020

Will close this PR for the reason mentioned above.

@edolstra edolstra closed this Jun 2, 2020
matthewbauer added a commit to matthewbauer/nix that referenced this pull request Jun 9, 2020
follow up of NixOS#3544

This allows hash="" so that it can be used for debugging purposes. For
instance, this gives you an error message like:

  warning: found empty hash, assuming you wanted 'sha256:0000000000000000000000000000000000000000000000000000'
  hash mismatch in fixed-output derivation '/nix/store/asx6qw1r1xk6iak6y6jph4n58h4hdmbm-nix':
    wanted: sha256:0000000000000000000000000000000000000000000000000000
    got:    sha256:0fpfhipl9v1mfzw2ffmxiyyzqwlkvww22bh9wcy4qrfslb4jm429
@matthewbauer
Copy link
Member Author

updated with changes here:

#3674

please take a look when you get a chance to.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants