fix(tvix/derivation): fix build after StorePath rename
This project was not previously covered by CI (fixed in this commit), so we didn't catch breakage due to a renamed module. This was noticed while rebasing a CL that has a dependency on this crate in its Nix build. Change-Id: Ic48570b9313e5f73e14daab50cf7ea70918c94d1 Reviewed-on: https://cl.tvl.fyi/c/depot/+/7778 Reviewed-by: flokli <flokli@flokli.de> Autosubmit: tazjin <tazjin@tvl.su> Tested-by: BuildkiteCI
This commit is contained in:
		
							parent
							
								
									3e03e59893
								
							
						
					
					
						commit
						1ebda9e13e
					
				
					 8 changed files with 91 additions and 90 deletions
				
			
		
							
								
								
									
										28
									
								
								tvix/Cargo.lock
									
										
									
										generated
									
									
									
								
							
							
						
						
									
										28
									
								
								tvix/Cargo.lock
									
										
									
										generated
									
									
									
								
							| 
						 | 
				
			
			@ -488,20 +488,6 @@ version = "2.3.3"
 | 
			
		|||
source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
			
		||||
checksum = "23d8666cb01533c39dde32bcbab8e227b4ed6679b2c925eba05feabea39508fb"
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "derivation"
 | 
			
		||||
version = "0.1.0"
 | 
			
		||||
dependencies = [
 | 
			
		||||
 "anyhow",
 | 
			
		||||
 "glob",
 | 
			
		||||
 "serde",
 | 
			
		||||
 "serde_json",
 | 
			
		||||
 "sha2",
 | 
			
		||||
 "test-case",
 | 
			
		||||
 "test-generator",
 | 
			
		||||
 "tvix-store-bin",
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "diff"
 | 
			
		||||
version = "0.1.13"
 | 
			
		||||
| 
						 | 
				
			
			@ -2197,6 +2183,20 @@ dependencies = [
 | 
			
		|||
 "tvix-eval",
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "tvix-derivation"
 | 
			
		||||
version = "0.1.0"
 | 
			
		||||
dependencies = [
 | 
			
		||||
 "anyhow",
 | 
			
		||||
 "glob",
 | 
			
		||||
 "serde",
 | 
			
		||||
 "serde_json",
 | 
			
		||||
 "sha2",
 | 
			
		||||
 "test-case",
 | 
			
		||||
 "test-generator",
 | 
			
		||||
 "tvix-store-bin",
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "tvix-eval"
 | 
			
		||||
version = "0.1.0"
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										118
									
								
								tvix/Cargo.nix
									
										
									
									
									
								
							
							
						
						
									
										118
									
								
								tvix/Cargo.nix
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -33,16 +33,6 @@ rec {
 | 
			
		|||
  # You can override the features with
 | 
			
		||||
  # workspaceMembers."${crateName}".build.override { features = [ "default" "feature1" ... ]; }.
 | 
			
		||||
  workspaceMembers = {
 | 
			
		||||
    "derivation" = rec {
 | 
			
		||||
      packageId = "derivation";
 | 
			
		||||
      build = internal.buildRustCrateWithFeatures {
 | 
			
		||||
        packageId = "derivation";
 | 
			
		||||
      };
 | 
			
		||||
 | 
			
		||||
      # Debug support which might change between releases.
 | 
			
		||||
      # File a bug if you depend on any for non-debug work!
 | 
			
		||||
      debug = internal.debugCrate { inherit packageId; };
 | 
			
		||||
    };
 | 
			
		||||
    "nix-cli" = rec {
 | 
			
		||||
      packageId = "nix-cli";
 | 
			
		||||
      build = internal.buildRustCrateWithFeatures {
 | 
			
		||||
| 
						 | 
				
			
			@ -63,6 +53,16 @@ rec {
 | 
			
		|||
      # File a bug if you depend on any for non-debug work!
 | 
			
		||||
      debug = internal.debugCrate { inherit packageId; };
 | 
			
		||||
    };
 | 
			
		||||
    "tvix-derivation" = rec {
 | 
			
		||||
      packageId = "tvix-derivation";
 | 
			
		||||
      build = internal.buildRustCrateWithFeatures {
 | 
			
		||||
        packageId = "tvix-derivation";
 | 
			
		||||
      };
 | 
			
		||||
 | 
			
		||||
      # Debug support which might change between releases.
 | 
			
		||||
      # File a bug if you depend on any for non-debug work!
 | 
			
		||||
      debug = internal.debugCrate { inherit packageId; };
 | 
			
		||||
    };
 | 
			
		||||
    "tvix-eval" = rec {
 | 
			
		||||
      packageId = "tvix-eval";
 | 
			
		||||
      build = internal.buildRustCrateWithFeatures {
 | 
			
		||||
| 
						 | 
				
			
			@ -1489,55 +1489,6 @@ rec {
 | 
			
		|||
        };
 | 
			
		||||
        resolvedDefaultFeatures = [ "alloc" "default" "std" ];
 | 
			
		||||
      };
 | 
			
		||||
      "derivation" = rec {
 | 
			
		||||
        crateName = "derivation";
 | 
			
		||||
        version = "0.1.0";
 | 
			
		||||
        edition = "2021";
 | 
			
		||||
        # We can't filter paths with references in Nix 2.4
 | 
			
		||||
        # See https://github.com/NixOS/nix/issues/5410
 | 
			
		||||
        src =
 | 
			
		||||
          if (lib.versionOlder builtins.nixVersion "2.4pre20211007")
 | 
			
		||||
          then lib.cleanSourceWith { filter = sourceFilter; src = ./derivation; }
 | 
			
		||||
          else ./derivation;
 | 
			
		||||
        dependencies = [
 | 
			
		||||
          {
 | 
			
		||||
            name = "anyhow";
 | 
			
		||||
            packageId = "anyhow";
 | 
			
		||||
          }
 | 
			
		||||
          {
 | 
			
		||||
            name = "glob";
 | 
			
		||||
            packageId = "glob";
 | 
			
		||||
          }
 | 
			
		||||
          {
 | 
			
		||||
            name = "serde";
 | 
			
		||||
            packageId = "serde";
 | 
			
		||||
            features = [ "derive" ];
 | 
			
		||||
          }
 | 
			
		||||
          {
 | 
			
		||||
            name = "sha2";
 | 
			
		||||
            packageId = "sha2";
 | 
			
		||||
          }
 | 
			
		||||
          {
 | 
			
		||||
            name = "tvix-store";
 | 
			
		||||
            packageId = "tvix-store";
 | 
			
		||||
          }
 | 
			
		||||
        ];
 | 
			
		||||
        devDependencies = [
 | 
			
		||||
          {
 | 
			
		||||
            name = "serde_json";
 | 
			
		||||
            packageId = "serde_json";
 | 
			
		||||
          }
 | 
			
		||||
          {
 | 
			
		||||
            name = "test-case";
 | 
			
		||||
            packageId = "test-case";
 | 
			
		||||
          }
 | 
			
		||||
          {
 | 
			
		||||
            name = "test-generator";
 | 
			
		||||
            packageId = "test-generator";
 | 
			
		||||
          }
 | 
			
		||||
        ];
 | 
			
		||||
 | 
			
		||||
      };
 | 
			
		||||
      "diff" = rec {
 | 
			
		||||
        crateName = "diff";
 | 
			
		||||
        version = "0.1.13";
 | 
			
		||||
| 
						 | 
				
			
			@ -6537,6 +6488,55 @@ rec {
 | 
			
		|||
          }
 | 
			
		||||
        ];
 | 
			
		||||
 | 
			
		||||
      };
 | 
			
		||||
      "tvix-derivation" = rec {
 | 
			
		||||
        crateName = "tvix-derivation";
 | 
			
		||||
        version = "0.1.0";
 | 
			
		||||
        edition = "2021";
 | 
			
		||||
        # We can't filter paths with references in Nix 2.4
 | 
			
		||||
        # See https://github.com/NixOS/nix/issues/5410
 | 
			
		||||
        src =
 | 
			
		||||
          if (lib.versionOlder builtins.nixVersion "2.4pre20211007")
 | 
			
		||||
          then lib.cleanSourceWith { filter = sourceFilter; src = ./derivation; }
 | 
			
		||||
          else ./derivation;
 | 
			
		||||
        dependencies = [
 | 
			
		||||
          {
 | 
			
		||||
            name = "anyhow";
 | 
			
		||||
            packageId = "anyhow";
 | 
			
		||||
          }
 | 
			
		||||
          {
 | 
			
		||||
            name = "glob";
 | 
			
		||||
            packageId = "glob";
 | 
			
		||||
          }
 | 
			
		||||
          {
 | 
			
		||||
            name = "serde";
 | 
			
		||||
            packageId = "serde";
 | 
			
		||||
            features = [ "derive" ];
 | 
			
		||||
          }
 | 
			
		||||
          {
 | 
			
		||||
            name = "sha2";
 | 
			
		||||
            packageId = "sha2";
 | 
			
		||||
          }
 | 
			
		||||
          {
 | 
			
		||||
            name = "tvix-store-bin";
 | 
			
		||||
            packageId = "tvix-store-bin";
 | 
			
		||||
          }
 | 
			
		||||
        ];
 | 
			
		||||
        devDependencies = [
 | 
			
		||||
          {
 | 
			
		||||
            name = "serde_json";
 | 
			
		||||
            packageId = "serde_json";
 | 
			
		||||
          }
 | 
			
		||||
          {
 | 
			
		||||
            name = "test-case";
 | 
			
		||||
            packageId = "test-case";
 | 
			
		||||
          }
 | 
			
		||||
          {
 | 
			
		||||
            name = "test-generator";
 | 
			
		||||
            packageId = "test-generator";
 | 
			
		||||
          }
 | 
			
		||||
        ];
 | 
			
		||||
 | 
			
		||||
      };
 | 
			
		||||
      "tvix-eval" = rec {
 | 
			
		||||
        crateName = "tvix-eval";
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
[package]
 | 
			
		||||
name = "derivation"
 | 
			
		||||
name = "tvix-derivation"
 | 
			
		||||
version = "0.1.0"
 | 
			
		||||
edition = "2021"
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										5
									
								
								tvix/derivation/default.nix
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								tvix/derivation/default.nix
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,5 @@
 | 
			
		|||
{ depot, ... }:
 | 
			
		||||
 | 
			
		||||
depot.tvix.crates.workspaceMembers.tvix-derivation.build.override {
 | 
			
		||||
  runTests = true;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -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::{ParseStorePathError, StorePath, STORE_DIR};
 | 
			
		||||
use tvix_store::store_path::{ParseStorePathError, StorePath, STORE_DIR};
 | 
			
		||||
 | 
			
		||||
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
 | 
			
		||||
pub struct Derivation {
 | 
			
		||||
| 
						 | 
				
			
			@ -242,7 +242,7 @@ impl Derivation {
 | 
			
		|||
                    hasher.update(":sha256:");
 | 
			
		||||
                    hasher.update(drv_replacement_str);
 | 
			
		||||
                    hasher.update(":");
 | 
			
		||||
                    hasher.update(tvix_store::nixpath::STORE_DIR);
 | 
			
		||||
                    hasher.update(STORE_DIR);
 | 
			
		||||
                    hasher.update(":");
 | 
			
		||||
 | 
			
		||||
                    // calculate the output_name_path, which is the part of the NixPath after the digest.
 | 
			
		||||
| 
						 | 
				
			
			@ -258,7 +258,7 @@ impl Derivation {
 | 
			
		|||
 | 
			
		||||
                    let abs_store_path = format!(
 | 
			
		||||
                        "{}/{}",
 | 
			
		||||
                        tvix_store::nixpath::STORE_DIR,
 | 
			
		||||
                        STORE_DIR,
 | 
			
		||||
                        build_store_path(false, &digest, &output_path_name)?
 | 
			
		||||
                    );
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -289,17 +289,14 @@ impl Derivation {
 | 
			
		|||
                        hasher.update(drv_replacement_str);
 | 
			
		||||
                    }
 | 
			
		||||
                    hasher.update(":");
 | 
			
		||||
                    hasher.update(tvix_store::nixpath::STORE_DIR);
 | 
			
		||||
                    hasher.update(STORE_DIR);
 | 
			
		||||
                    hasher.update(":");
 | 
			
		||||
                    hasher.update(name);
 | 
			
		||||
                    hasher.finalize()
 | 
			
		||||
                };
 | 
			
		||||
 | 
			
		||||
                let abs_store_path = format!(
 | 
			
		||||
                    "{}/{}",
 | 
			
		||||
                    tvix_store::nixpath::STORE_DIR,
 | 
			
		||||
                    build_store_path(false, &digest, name)?
 | 
			
		||||
                );
 | 
			
		||||
                let abs_store_path =
 | 
			
		||||
                    format!("{}/{}", STORE_DIR, build_store_path(false, &digest, name)?);
 | 
			
		||||
 | 
			
		||||
                self.outputs.insert(
 | 
			
		||||
                    "out".to_string(),
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,7 +1,7 @@
 | 
			
		|||
use serde::{Deserialize, Serialize};
 | 
			
		||||
use tvix_store::nixpath::StorePath;
 | 
			
		||||
use tvix_store::store_path::StorePath;
 | 
			
		||||
 | 
			
		||||
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
 | 
			
		||||
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize)]
 | 
			
		||||
pub struct Output {
 | 
			
		||||
    pub path: String,
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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::StorePath;
 | 
			
		||||
use tvix_store::store_path::StorePath;
 | 
			
		||||
 | 
			
		||||
const RESOURCES_PATHS: &str = "src/tests/derivation_tests";
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -252,8 +252,7 @@ fn output_path_construction() {
 | 
			
		|||
 | 
			
		||||
    let bar_drv_path = bar_drv
 | 
			
		||||
        .calculate_derivation_path("bar")
 | 
			
		||||
        .expect("must succeed")
 | 
			
		||||
        .to_absolute_path();
 | 
			
		||||
        .expect("must succeed");
 | 
			
		||||
 | 
			
		||||
    // assemble foo env
 | 
			
		||||
    let mut foo_env: BTreeMap<String, String> = BTreeMap::new();
 | 
			
		||||
| 
						 | 
				
			
			@ -275,7 +274,7 @@ fn output_path_construction() {
 | 
			
		|||
 | 
			
		||||
    // assemble foo input_derivations
 | 
			
		||||
    let mut foo_input_derivations: BTreeMap<String, Vec<String>> = BTreeMap::new();
 | 
			
		||||
    foo_input_derivations.insert(bar_drv_path.to_absolute_string(), vec!["out".to_string()]);
 | 
			
		||||
    foo_input_derivations.insert(bar_drv_path.to_absolute_path(), vec!["out".to_string()]);
 | 
			
		||||
 | 
			
		||||
    // assemble foo itself
 | 
			
		||||
    let mut foo_drv = Derivation {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,6 +1,6 @@
 | 
			
		|||
use crate::{derivation::Derivation, write::DOT_FILE_EXT};
 | 
			
		||||
use anyhow::bail;
 | 
			
		||||
use tvix_store::nixpath::StorePath;
 | 
			
		||||
use tvix_store::store_path::StorePath;
 | 
			
		||||
 | 
			
		||||
impl Derivation {
 | 
			
		||||
    /// validate ensures a Derivation struct is properly populated,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue