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

fetchFromGitHub allows hash and content specified to diverge #61690

Closed
xaverdh opened this issue May 18, 2019 · 2 comments
Closed

fetchFromGitHub allows hash and content specified to diverge #61690

xaverdh opened this issue May 18, 2019 · 2 comments

Comments

@xaverdh
Copy link
Contributor

xaverdh commented May 18, 2019

Issue description

fetchFromGitHub (and its friends as well?) can effectively "accept" hashes which do not match the referenced content. This happens in #61674 for example, where the revision was changed, but the hash wasn't updated accordingly by accident.
This is probably due to caching. The hash remains the same, so there is no attempt to rebuild the derivation, which would detect the mismatch. So the content-hash combination as specified in the nix file becomes invalid, but this is not detected.

Steps to reproduce

Build a derivation which uses fetchFromGitHub, then change rev without changing the hash.

@danieldk
Copy link
Contributor

This true for (I think) all fetchers. fetchFromGitHub uses fetchzip when fetchSubmodules is false. Also see this issue, which has some discussions:

NixOS/nix#969

@vcunat
Copy link
Member

vcunat commented May 19, 2019

Yes, it's a feature, basically. Let's not create yet another thread for discussing it. You can join some of the existing ones.

TL;DR: fetchers are fixed-output derivations, i.e. content-addressable. If you specify a hash that you have already (or can substitute etc.), nix won't attempt to build it. One of original motivations is switching mirrors without rebuilds.

@vcunat vcunat closed this as completed May 19, 2019
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

No branches or pull requests

3 participants