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

fetchurl: better support multiple hash types #15441

Conversation

aneeshusa
Copy link
Contributor

  • Tested using sandboxing
    (nix.useSandbox on NixOS,
    or option build-use-sandbox in nix.conf
    on non-NixOS)
  • Built on platform(s)
    • NixOS
    • OS X
    • Linux
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Fits CONTRIBUTING.md.

Instead of requiring that Nix be new enough to handle the sha512 hash
type if it is passed to fetchurl with an assert, instead fallback to
other hash types if Nix is not new enough. This enables passing
multiple hash types (e.g. sha256 and sha512) to fetchurl in a way that
can be evaluated on both new and old Nixes that do/do not support the
newer hash (sha512).

See conversation at #15048.

This did not cause any rebuilds for me (with Nix version 1.11.2); I did not test with an older Nix but I will try to do that soon. If this change is accepted, I would like to have future changes require both sha256 and sha512 hashes so they can evaluate on both old and new Nix versions.

cc @vcunat

Instead of requiring that Nix be new enough to handle the sha512 hash
type if it is passed to fetchurl with an assert, instead fallback to
other hash types if Nix is not new enough. This enables passing
multiple hash types (e.g. sha256 and sha512) to fetchurl in a way that
can be evaluated on both new and old Nixes that do/do not support the
newer hash (sha512).

See conversation at NixOS#15048.
@mention-bot
Copy link

By analyzing the blame information on this pull request, we identified @edolstra, @domenkozar and @urkud to be potential reviewers

@aneeshusa aneeshusa mentioned this pull request May 13, 2016
7 tasks
@aneeshusa
Copy link
Contributor Author

I added a commit that gives util-linux both sha512 and sha256 hashes, and it seems to evaluate with both Nix 1.10 and Nix 1.11.2. Further testing would be appreciated to make sure this works properly with both old and new Nix versions.

@bjornfor
Copy link
Contributor

+1 for reverting to sha256 in util-linux (your 2nd commit).

I'm less sure about the 1st commit. As long as nix will rebuild when changing hash type (that's unfortunate!), I think there is little value in allowing sha512 for newer nix, because old nix users cannot use the binaries produced by the new nix (they have to build it themself, as @vcunat pointed out in #15048 (comment)).

Due to it being a mass-rebuild (!), I'd like to defer to others to decide whether to merge (the util-linux commit) to staging or master.

@aneeshusa
Copy link
Contributor Author

aneeshusa commented May 14, 2016

What's our story for upgrading to newer hashes? Being stuck on sha256 forever is not something that I'm OK with; we need to have cryptographic agility to be able to update to newer, stronger hashes over time. Maybe this will require some changes to Nix itself, or maybe we should have a policy about how long to wait for a newer Nix version to disseminate (1 major NixOS version?) before bumping the minimum required version, but IMO it's important that we find a story for this that preserves backwards compatibility.

Personally, I use a number of tweaks that mean I have to recompile everything anyways, so I don't mind. Another point is that I'm assuming Hydra has a new Nix and will use sha512 for the binary cache, so only users with old Nix versions will need to recompile; this may be a good incentive to have them upgrade sooner rather than later.

Also note that the second commit has both sha512 and sha256, so without the first commit fetchurl will always try to use sha512, but will throw an assert if Nix is too old.

@aneeshusa
Copy link
Contributor Author

Also, I don't see why this is a mass-rebuild; this just causes fetchurl to skip looking at sha512 if Nix is too old, and the only package that this would affect is util-linux with the second commit, which can now be evaluate on old Nix instead of simply throwing an assert.

@bjornfor
Copy link
Contributor

Oh, right, it isn't mass-rebuild (I thought it did s/sha512/sha256/, but it really adds sha256).

But how important is it to have sha512 now, as opposed to waiting one more release cycle (6 months)? I'm asking seriously, I don't know what kind of risk it poses.

Another possibility, IMHO, would be to backport sha512 support to Nix 1.10, the version used on NixOS 15.09.

Anyway, I'm not against this patch. I just said I was unsure about the 1st commit, as I explained above.

@vcunat
Copy link
Member

vcunat commented May 15, 2016

I didn't follow this discussion and staged 26e8e3e for now, with the glibc security rebuild. I think the main incentive for sha512 was changes in Mozilla's releases NixOS/nix#679 that made getting other hashes from them more difficult.

@aneeshusa
Copy link
Contributor Author

@bjornfor @vcunat How do you feel about this PR now? It's one release cycle later (16.09 is almost here), more packages are using sha512 (see #16391 for example), and makes it easier to move from sha256 -> sha512 by supporting multiple hashes in fetchurl allowing users with older Nix to continue evaluating packages.

@bjornfor
Copy link
Contributor

Hm, I'd like to back out of this discussion. I'll leave the decision whether this is the right approach to more skillful / knowledgeable Nix'ers.

@spacekitteh
Copy link
Contributor

@grahamc security, enhancement

@dezgeg
Copy link
Contributor

dezgeg commented Mar 19, 2017

Another release cycle is up soon, so this workaround shouldn't be needed (everyone should be running a recent enough Nix soon). Plus, the fact that evaluating the same packages on different Nix version sounds highly undesirable. Closing.

@dezgeg dezgeg closed this Mar 19, 2017
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

6 participants