diff options
author | Florian Klink <flokli@flokli.de> | 2023-03-13T22·52+0100 |
---|---|---|
committer | flokli <flokli@flokli.de> | 2023-03-14T18·26+0000 |
commit | 5f260edf7fba9a6ad1e0ee16779df11d92686828 (patch) | |
tree | 587b94d271c2d748164bde1a2bc5c5a093557d70 /tvix/cli/src/derivation.rs | |
parent | 32999cb6f60ec89099f1f5295038cfeca2fb106a (diff) |
refactor(tvix/nix-compat): replace calculate_drv_replacement_str r/5995
Call this function derivation_or_fod_hash, and return a NixHash. This is more in line with how cppnix calls this, and allows using to_nix_hash_string() in some places. Change-Id: Iebf5355f08ed5c9a044844739350f829f874f0ce Reviewed-on: https://cl.tvl.fyi/c/depot/+/8293 Reviewed-by: tazjin <tazjin@tvl.su> Tested-by: BuildkiteCI
Diffstat (limited to 'tvix/cli/src/derivation.rs')
-rw-r--r-- | tvix/cli/src/derivation.rs | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/tvix/cli/src/derivation.rs b/tvix/cli/src/derivation.rs index 15c4c6f858f7..61c4489954f1 100644 --- a/tvix/cli/src/derivation.rs +++ b/tvix/cli/src/derivation.rs @@ -339,21 +339,27 @@ mod derivation_builtins { // eval data structures. drv.validate(false).map_err(Error::InvalidDerivation)?; - let tmp_replacement_str = - drv.calculate_drv_replacement_str(|drv| known_paths.get_replacement_string(drv)); + // Calculate the derivation_or_fod_hash for the current derivation. + // This one is still intermediate (so not added to known_paths) + let derivation_or_fod_hash_tmp = + drv.derivation_or_fod_hash(|drv| known_paths.get_hash_derivation_modulo(drv)); - drv.calculate_output_paths(&name, &tmp_replacement_str) + // Mutate the Derivation struct and set output paths + drv.calculate_output_paths(&name, &derivation_or_fod_hash_tmp) .map_err(Error::InvalidDerivation)?; - let actual_replacement_str = - drv.calculate_drv_replacement_str(|drv| known_paths.get_replacement_string(drv)); - let derivation_path = drv .calculate_derivation_path(&name) .map_err(Error::InvalidDerivation)?; - known_paths - .add_replacement_string(derivation_path.to_absolute_path(), &actual_replacement_str); + // recompute the hash derivation modulo and add to known_paths + let derivation_or_fod_hash_final = + drv.derivation_or_fod_hash(|drv| known_paths.get_hash_derivation_modulo(drv)); + + known_paths.add_hash_derivation_modulo( + derivation_path.to_absolute_path(), + &derivation_or_fod_hash_final, + ); // mark all the new paths as known let output_names: Vec<String> = drv.outputs.keys().map(Clone::clone).collect(); |