Use SRI hash (strings) as the official JSON format for Hash after all#14743
Merged
Ericson2314 merged 3 commits intomasterfrom Dec 8, 2025
Merged
Use SRI hash (strings) as the official JSON format for Hash after all#14743Ericson2314 merged 3 commits intomasterfrom
Ericson2314 merged 3 commits intomasterfrom
Conversation
This will be used for unit testing.
Floating CA outputs just have a hash algorith, not a whole hash. It is fixed ones which are a pair of a method and a hash, just like the `ca` field of store object info.
38b26cd to
ee650d2
Compare
xokdvium
reviewed
Dec 8, 2025
xokdvium
approved these changes
Dec 8, 2025
The fact that we were introducing a conversion from the output of `nix path-info` into the input of `builtins.fetchTree` was the deciding factor. We want scripting outputs into inputs like that to be easy. Since JSON strings and objects are trivially distinguishable, we still have the option of introducing the JSON format as an alternative input scheme in the future, should we want to. (The output format would still be SRI in that case, presumably.)
ee650d2 to
61de922
Compare
Mic92
reviewed
Dec 8, 2025
| narHash_obj = path_info_dict[os.path.basename(tarball_store_path)]["narHash"] | ||
| # Convert from structured format {"algorithm": "sha256", "format": "base16", "hash": "..."} to SRI string | ||
| tarball_hash_sri = substituter.succeed(f"nix hash convert --to sri {narHash_obj['algorithm']}:{narHash_obj['hash']}").strip() | ||
| # narHash is already in SRI format |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
The fact that we were introducing a conversion from the output of
nix path-infointo the input ofbuiltins.fetchTreewas the deciding factor. We want scripting outputs into inputs like that to be easy.Context
Since JSON strings and objects are trivially distinguishable, we still have the option of introducing the JSON format as an alternative input scheme in the future, should we want to. (The output format would still be SRI in that case, presumably.)
Add 👍 to pull requests you find important.
The Nix maintainer team uses a GitHub project board to schedule and track reviews.