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 <flokli@flokli.de>
Tested-by: BuildkiteCI
This commit is contained in:
John Ericson 2023-03-31 10:20:04 -04:00 committed by John Ericson
parent b4670bfbd1
commit 26c68f8e89
9 changed files with 268 additions and 125 deletions

View file

@ -1,7 +1,7 @@
use crate::derivation::output::Output;
use crate::derivation::Derivation;
use crate::nixhash::NixHash;
use crate::store_path::{build_store_path_from_references, StorePath};
use crate::store_path::StorePath;
use std::collections::BTreeSet;
use std::fs::File;
use std::io::Read;