-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
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
fetchgit: add SRI hash support #79987
Conversation
, rev ? "HEAD" | ||
|
||
, # SRI hash. | ||
hash ? "" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be called narHash
for consistency with builtins.fetchX
(NixOS/nix@d4df99a).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should I rename it in 267c8d6 as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, probably. We could also rename everything to hash
, but that's ambiguous in functions that take both a file and a NAR hash...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it make sense to call it narHash
if it can also be used for outputHashMode = "flat"
? If I understand the docs correctly, hash of the NAR is only used for FOD when using recursive
output hash mode.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
functions that take both a file and a NAR hash
I am not sure what you mean.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alternately, we could use outputHash
directly, as that is what gets passed to Nix in the end.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we are using SRI hashes, using integrity
attribute name like in HTML might actually fit even better.
a63aed3
to
d1d0961
Compare
Until the attribute name issue is clarified, I cherry-picked the |
cc @edolstra I think it's really important we decide what the attribute for #79987 (comment) is going to be. There's already some stigma on base64 encoding and sri in nixpkgs #89423 #89423 and this is awfully difficult, for example, to explain to people that they can't use |
|
@edolstra What attribute will we use for flat files then? And why do we need to distinguish between NAR hash and flat file hash by the checksum attribute? It could just be hidden inside the fetch functions and switched through |
Flat file hashes are used in many places, e.g. |
@edolstra I meant what attribute would we use for flat file hashes if we want to distinguish them from NAR hashes. |
Including SRI hash support
to sync it with fetchgit
I agree with @jtojnar. Choosing between a file hash or a NAR hash seems like more of an implementation detail of the fetcher, rather than something that always needs to be specified by the package maintainer. I think if we required maintainers to declare it explicitly, it would cause a lot of confusion, especially for beginners. For example, this would use a file hash: fetchurl {
url = "https://releases.nixos.org/nix/nix-2.3.10/install";
hash = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=";
} But this would require a NAR hash: fetchurl {
url = "https://releases.nixos.org/nix/nix-2.3.10/install";
executable = true;
narHash = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=";
} |
I marked this as stale due to inactivity. → More info |
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: |
support for hashes added in 5c2b1b6 |
Motivation for this change
Sync fetchgit's hash support with fetchurl's to add support for SRI hashes (introduced in 267c8d6).
Things done
sandbox
innix.conf
on non-NixOS linux)nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
./result/bin/
)nix path-info -S
before and after)