-
-
Notifications
You must be signed in to change notification settings - Fork 14.9k
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: accept SRI in hex and base32 #199660
base: master
Are you sure you want to change the base?
Conversation
- only implemented for sha256 and sha512 - applies also to fetchFrom* as those wrap fetchurl
Just to allow testing the PoC, at least the base16 case, as that's commonly used by upstreams.
SRI is an actual standard, with a precise definition, and silently diverging from it would be problematic IMO for anyone:
That's already a significant problem with the legacy “base32” encoding; I legitimately do not understand the motivation for (re)creating more of those issues, that will stay in nixpkgs for at least another decade. |
base16 hashes seem way more widespread in practice than base64/SRI, so I personally view SRI as a "less standard" approach. But I'm glad I got at least some feedback on this PR. |
I'm afraid I do not follow:
Moreover, that doesn't really address any of the issues I raised? Anyone needing to deal with If you are trying to argue
You are welcome. |
PS: In case that wasn't clear, I don't care all that much what encoding
Using SRI fulfills all those (so it doesn't have the issues I raised above) and is what |
The tooling argument: as the original value is base16 typically, you either need to complicate the tools that generate nix expressions (conversion to base64; including humans copy&pasting so far) or those that consume the nix expressions (accept more than base64). I don't see why the first would be clearly superior. I thought it's better to have an option to keep the same format as what is published elsewhere (typically). That option has always been here through attributes like Of course it's about opinions, to some extent 🤷🏽 |
In all cases, tools that consume some upstream manifest (be it checksum files, indexes in language-specific package managers' repositories, etc.) must extract the hash, but they know (by definition) what formats they are dealing with. If That's a lot more complexity; to put a concrete quantity on it, reliably recognising and decoding all 3 formats took me 100+ lines of Python (and a couple migraines...), and that's not a particularly verbose language. On the other hand, the conversion from a standard format (hex or base64) is pretty trivial; even in a shell script, that's just a call to
I honestly don't know that this matters so much:
However, having a uniform format makes having automation at all, a lot easier (speaking as someone who just burnt a lot of her remaining sanity to successfully parse hashes from nixpkgs) and I believe that's what we should aim for, in terms of minimizing developer toil. The same argument holds, I think, for people wanting to verify the correct hashes are in nixpkgs, but even moreso :
Oh, OK. That wasn't evident to me at all that this was what the proposal addresses. I agree it would make sense to (eventually) deprecate |
PS: One possibly-unobvious goal, in making a maintainer script and PRs to progressively move drvs to For instance, one of the |
|
Agreed! I've started a list of which tools (still) use the nix32 encoding as their default (or only) option, and I plan to submit PRs eventually. Probably not in the very-near future though: I'm not home for some days, and may be quite busy when I come back.
|
Yes, but I suspect that it's "stabilized" to the point that changing the default output format won't be accepted. Cross-ref: NixOS/nix#7690 |
Yes, that PR did implement support for SRI hashes in I wasn't necessarily referring to it specifically, in the context of updating tools' defaults, though I guess it could make sense, esp. if it's called by |
Proof of concept stemming from NixOS/rfcs#131
Problem statement:
fetch*
hashes would be nice; the currently most common aresha256
andhash
hash
attribute on nixpkgs level) only support base64 encoding