From 26c68f8e892633bde4aeebbfc0e4ae7ee571687d Mon Sep 17 00:00:00 2001 From: John Ericson Date: Fri, 31 Mar 2023 10:20:04 -0400 Subject: refactor(nix-compat): Properly encapsulate store path construction Before there was code scattered about (e.g. text hashing module and derivation output computation) constructing store paths from low level building blocks --- there was some duplication and it was easy to make nonsense store paths. Now, we have roughly the same "safe-ish" ways of constructing them as C++ Nix, and only those are exposed: - Make text hashed content-addressed store paths - Make other content-addressed store paths - Make input-addressed fixed output hashes Change-Id: I122a3ee0802b4f45ae386306b95b698991be89c8 Reviewed-on: https://cl.tvl.fyi/c/depot/+/8411 Reviewed-by: flokli Tested-by: BuildkiteCI --- tvix/cli/src/derivation.rs | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'tvix/cli/src/derivation.rs') diff --git a/tvix/cli/src/derivation.rs b/tvix/cli/src/derivation.rs index 23c49d3d0974..cf15ebbb0dc3 100644 --- a/tvix/cli/src/derivation.rs +++ b/tvix/cli/src/derivation.rs @@ -412,16 +412,14 @@ mod derivation_builtins { // TODO: fail on derivation references (only "plain" is allowed here) - let path = nix_compat::store_path::build_store_path_from_references( - name.as_str(), - content.as_str(), - refs, - ) - .map_err(|_e| { - nix_compat::derivation::DerivationError::InvalidOutputName(name.as_str().to_string()) - }) - .map_err(Error::InvalidDerivation)? - .to_absolute_path(); + let path = nix_compat::store_path::build_text_path(name.as_str(), content.as_str(), refs) + .map_err(|_e| { + nix_compat::derivation::DerivationError::InvalidOutputName( + name.as_str().to_string(), + ) + }) + .map_err(Error::InvalidDerivation)? + .to_absolute_path(); state.borrow_mut().plain(&path); -- cgit 1.4.1