Merge text hashing logic
#263
Opened by flokli at
Nix has a concept of "text hashing", used in two different places right now:
tvix/nix-compat/src/derivation/mod.rs@calculate_derivation_path
Fields, separated by :
:
- "text"
- the list of paths from input_sources and input_derivations in a stored list, individually joined by
:
- the sha256 nix_hash_string of the aterm representation of the derivation
- the storeDir
- the
name
of the derivation, followed by a.drv
The Sha256 digest of this is then passed to hash.CompressHash(digest, 20), to produce a store path.
tvix/nix-compat/src/derivation/utils.rs@path_with_references
Fields, separated by :
:
- "text"
- all references passed in the
references
arg (strings), individually joined by:
- the sha256 nix_hash_string of the contents (contents themselves passed in the
content
arg) - the storeDir
- the
name
passed to thebuiltins.toFile
builtin
The Sha256 digest of this is then passed to hash.CompressHash(digest, 20), to produce a store path.
This function is only used in the implementation of builtins.toFile
.
/// Build a store path for a literal text file in the store that may /// contain references. pub fn path_with_references<S: AsRef<str>, I: IntoIterator<Item = S>, C: AsRef<[u8]>>( name: &str, content: C, references: I, )
We should probably factor this code out into a common function.
Done in cl/8364.
flokli at 2023-03-30T11·35+00
- flokli closed this issue at 2023-03-30T14·15+00