about summary refs log tree commit diff
path: root/tvix/nix-compat/src/texthash.rs
diff options
context:
space:
mode:
authorJohn Ericson <John.Ericson@Obsidian.Systems>2023-03-30T21·30-0400
committerJohn Ericson <git@johnericson.me>2023-03-31T18·46+0000
commitdf78a4d24ee88289d979c2068ddf59d949c41004 (patch)
treefc31caf678c6f91778428a919354db65613a72f2 /tvix/nix-compat/src/texthash.rs
parentce502bdc892e2f8f24ac2babe96791542b0bbec3 (diff)
refactor(tvix/nix-compat): Inline `texthash` mod r/6067
It is moved into `store_path::utils` with the other path builders.

Change-Id: I3257170e442af5d83bcf79e63fa7387dd914597c
Reviewed-on: https://cl.tvl.fyi/c/depot/+/8410
Reviewed-by: flokli <flokli@flokli.de>
Tested-by: BuildkiteCI
Diffstat (limited to '')
-rw-r--r--tvix/nix-compat/src/texthash.rs42
1 files changed, 0 insertions, 42 deletions
diff --git a/tvix/nix-compat/src/texthash.rs b/tvix/nix-compat/src/texthash.rs
deleted file mode 100644
index 959a4dc3dc..0000000000
--- a/tvix/nix-compat/src/texthash.rs
+++ /dev/null
@@ -1,42 +0,0 @@
-use sha2::{Digest, Sha256};
-
-use crate::{nixhash::NixHash, store_path};
-
-/// This contains the Nix logic to create "text hash strings", which are used
-/// in `builtins.toFile`, as well as in Derivation Path calculation.
-///
-/// A text hash is calculated by concatenating the following fields, separated by a `:`:
-///
-///  - text
-///  - references, individually joined by `:`
-///  - the nix_hash_string representation of the sha256 digest of some contents
-///  - the value of `storeDir`
-///  - the name
-pub fn text_hash_string<S: AsRef<str>, I: IntoIterator<Item = S>, C: AsRef<[u8]>>(
-    name: &str,
-    content: C,
-    references: I,
-) -> String {
-    let mut s = String::from("text:");
-
-    for reference in references {
-        s.push_str(reference.as_ref());
-        s.push(':');
-    }
-
-    // the nix_hash_string representation of the sha256 digest of some contents
-    s.push_str(
-        &{
-            let content_digest = {
-                let hasher = Sha256::new_with_prefix(content);
-                hasher.finalize()
-            };
-            NixHash::new(crate::nixhash::HashAlgo::Sha256, content_digest.to_vec())
-        }
-        .to_nix_hash_string(),
-    );
-
-    s.push_str(&format!(":{}:{}", store_path::STORE_DIR, name));
-
-    s
-}