From 5f2c2e79e1778cda877d6122dd24be08740c8720 Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Thu, 30 Mar 2023 14:01:38 +0200 Subject: refactor(tvix/nix-compat): move build_store_path out of derivation This doesn't have anything to do with ATerms, we just happen to be using the aterm representation of a Derivation as contents. Moving this into store_path/utils.rs makes these things much cleaner - Have a build_store_path_from_references function, and a build_store_path_from_fingerprint helper function that makes use of it. build_store_path_from_references is invoked from the derivation module which can be used to calculate the derivation path. In the derivation module, we also invoke build_store_path_from_fingerprint during the output path calculation. Change-Id: Ia8d61a5e8e5d3f396f93593676ed3f5d1a3f1d66 Reviewed-on: https://cl.tvl.fyi/c/depot/+/8367 Autosubmit: flokli Reviewed-by: tazjin Tested-by: BuildkiteCI --- tvix/nix-compat/src/lib.rs | 18 ------------------ 1 file changed, 18 deletions(-) (limited to 'tvix/nix-compat/src/lib.rs') diff --git a/tvix/nix-compat/src/lib.rs b/tvix/nix-compat/src/lib.rs index ec9ddd1ffa7b..2aac179bcfce 100644 --- a/tvix/nix-compat/src/lib.rs +++ b/tvix/nix-compat/src/lib.rs @@ -1,5 +1,3 @@ -use sha2::{Digest, Sha256}; - pub mod derivation; pub mod nar; pub mod nixbase32; @@ -8,19 +6,3 @@ mod nixhash_algos; mod nixhash_with_mode; pub mod store_path; mod texthash; - -/// Nix placeholders (i.e. values returned by `builtins.placeholder`) -/// are used to populate outputs with paths that must be -/// string-replaced with the actual placeholders later, at runtime. -/// -/// The actual placeholder is basically just a SHA256 hash encoded in -/// cppnix format. -pub fn hash_placeholder(name: &str) -> String { - let digest = { - let mut hasher = Sha256::new(); - hasher.update(format!("nix-output:{}", name)); - hasher.finalize() - }; - - format!("/{}", nixbase32::encode(&digest)) -} -- cgit 1.4.1