From c89af03a030b8447954d17972ce6f64fb6d42f57 Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Fri, 6 Jan 2023 16:27:27 +0100 Subject: refactor(tvix/store): rename NixPath to StorePath As discussed in #tvl, this is a more common term for it. Change-Id: I9b904222b8c076f82192c9b7f0b42be171614ab7 Reviewed-on: https://cl.tvl.fyi/c/depot/+/7776 Reviewed-by: tazjin Tested-by: BuildkiteCI --- tvix/derivation/src/derivation.rs | 14 +++++++------- tvix/derivation/src/output.rs | 4 ++-- tvix/derivation/src/tests/mod.rs | 6 +++--- tvix/derivation/src/validate.rs | 6 +++--- 4 files changed, 15 insertions(+), 15 deletions(-) (limited to 'tvix/derivation/src') diff --git a/tvix/derivation/src/derivation.rs b/tvix/derivation/src/derivation.rs index 2afe672e2e..bf26e1baac 100644 --- a/tvix/derivation/src/derivation.rs +++ b/tvix/derivation/src/derivation.rs @@ -5,7 +5,7 @@ use serde::{Deserialize, Serialize}; use sha2::{Digest, Sha256}; use std::{collections::BTreeMap, fmt, fmt::Write}; use tvix_store::nixbase32::NIXBASE32; -use tvix_store::nixpath::{NixPath, ParseNixPathError, STORE_DIR}; +use tvix_store::nixpath::{ParseStorePathError, StorePath, STORE_DIR}; #[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] pub struct Derivation { @@ -34,10 +34,10 @@ fn build_store_path( is_derivation: bool, path_hash: &[u8], name: &str, -) -> Result { +) -> Result { let compressed = nix_hash::compress_hash(path_hash, 20); if is_derivation { - NixPath::from_string( + StorePath::from_string( format!( "{}-{}{}", NIXBASE32.encode(&compressed), @@ -47,7 +47,7 @@ fn build_store_path( .as_str(), ) } else { - NixPath::from_string(format!("{}-{}", NIXBASE32.encode(&compressed), name,).as_str()) + StorePath::from_string(format!("{}-{}", NIXBASE32.encode(&compressed), name,).as_str()) } } @@ -105,8 +105,8 @@ impl Derivation { /// - Write the .drv A-Term contents to a hash function /// - Take the digest, run hash.CompressHash(digest, 20) on it. /// - Encode it with nixbase32 - /// - Use it (and the name) to construct a NixPath. - pub fn calculate_derivation_path(&self, name: &str) -> Result { + /// - Use it (and the name) to construct a [StorePath]. + pub fn calculate_derivation_path(&self, name: &str) -> Result { let mut hasher = Sha256::new(); // collect the list of paths from input_sources and input_derivations @@ -223,7 +223,7 @@ impl Derivation { &mut self, name: &str, drv_replacement_str: &str, - ) -> Result<(), ParseNixPathError> { + ) -> Result<(), ParseStorePathError> { let mut hasher = Sha256::new(); // Check if the Derivation is fixed output, because they cause diff --git a/tvix/derivation/src/output.rs b/tvix/derivation/src/output.rs index b038f6b5fc..02ba7e42e8 100644 --- a/tvix/derivation/src/output.rs +++ b/tvix/derivation/src/output.rs @@ -1,5 +1,5 @@ use serde::{Deserialize, Serialize}; -use tvix_store::nixpath::NixPath; +use tvix_store::nixpath::StorePath; #[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] pub struct Output { @@ -23,7 +23,7 @@ impl Output { } pub fn validate(&self) -> anyhow::Result<()> { - NixPath::from_absolute_path(&self.path)?; + StorePath::from_absolute_path(&self.path)?; Ok(()) } } diff --git a/tvix/derivation/src/tests/mod.rs b/tvix/derivation/src/tests/mod.rs index 700a258605..8d1771f711 100644 --- a/tvix/derivation/src/tests/mod.rs +++ b/tvix/derivation/src/tests/mod.rs @@ -6,7 +6,7 @@ use std::io::Read; use std::path::Path; use test_case::test_case; use test_generator::test_resources; -use tvix_store::nixpath::NixPath; +use tvix_store::nixpath::StorePath; const RESOURCES_PATHS: &str = "src/tests/derivation_tests"; @@ -66,7 +66,7 @@ fn derivation_path(name: &str, expected_path: &str) { assert_eq!( derivation.calculate_derivation_path(name).unwrap(), - NixPath::from_string(expected_path).unwrap() + StorePath::from_string(expected_path).unwrap() ); } @@ -309,7 +309,7 @@ fn output_path_construction() { assert_eq!(foo_drv_expected, foo_drv); assert_eq!( - NixPath::from_string("4wvvbi4jwn0prsdxb7vs673qa5h9gr7x-foo.drv").expect("must succeed"), + StorePath::from_string("4wvvbi4jwn0prsdxb7vs673qa5h9gr7x-foo.drv").expect("must succeed"), foo_drv .calculate_derivation_path("foo") .expect("must succeed") diff --git a/tvix/derivation/src/validate.rs b/tvix/derivation/src/validate.rs index e0f62a323f..4e05038339 100644 --- a/tvix/derivation/src/validate.rs +++ b/tvix/derivation/src/validate.rs @@ -1,6 +1,6 @@ use crate::{derivation::Derivation, write::DOT_FILE_EXT}; use anyhow::bail; -use tvix_store::nixpath::NixPath; +use tvix_store::nixpath::StorePath; impl Derivation { /// validate ensures a Derivation struct is properly populated, @@ -35,7 +35,7 @@ impl Derivation { // Validate all input_derivations for (input_derivation_path, output_names) in &self.input_derivations { // Validate input_derivation_path - NixPath::from_absolute_path(input_derivation_path)?; + StorePath::from_absolute_path(input_derivation_path)?; if !input_derivation_path.ends_with(DOT_FILE_EXT) { bail!( "derivation {} does not end with .drv", @@ -70,7 +70,7 @@ impl Derivation { // Validate all input_sources for (i, input_source) in self.input_sources.iter().enumerate() { - NixPath::from_absolute_path(input_source)?; + StorePath::from_absolute_path(input_source)?; if i > 0 && self.input_sources[i - 1] >= *input_source { bail!( -- cgit 1.4.1