feat(tvix/nix-compat): input_sources as StorePath

https: //b.tvl.fyi/issues/264
Change-Id: I7a235734dc1f8e93e387a04ba369f3b702c6d5b6
Reviewed-on: https://cl.tvl.fyi/c/depot/+/10992
Autosubmit: Peter Kolloch <info@eigenvalue.net>
Reviewed-by: flokli <flokli@flokli.de>
Reviewed-by: Peter Kolloch <info@eigenvalue.net>
Tested-by: BuildkiteCI
This commit is contained in:
Peter Kolloch 2024-02-21 14:07:37 +07:00 committed by clbot
parent c06fb01b3b
commit 035f617b7f
6 changed files with 53 additions and 31 deletions

View file

@ -33,6 +33,13 @@ pub const QUOTE: char = '"';
/// the context a lot.
pub(crate) trait AtermWriteable: Display {
fn aterm_write(&self, writer: &mut impl Write) -> std::io::Result<()>;
fn aterm_bytes(&self) -> Vec<u8> {
let mut bytes = Vec::new();
self.aterm_write(&mut bytes)
.expect("unexpected write errors to Vec");
bytes
}
}
impl AtermWriteable for StorePathRef<'_> {
@ -182,12 +189,15 @@ pub(crate) fn write_input_derivations(
pub(crate) fn write_input_sources(
writer: &mut impl Write,
input_sources: &BTreeSet<String>,
input_sources: &BTreeSet<StorePath>,
) -> Result<(), io::Error> {
write_char(writer, BRACKET_OPEN)?;
write_array_elements(
writer,
&input_sources.iter().map(String::from).collect::<Vec<_>>(),
&input_sources
.iter()
.map(StorePath::to_absolute_path)
.collect::<Vec<_>>(),
)?;
write_char(writer, BRACKET_CLOSE)?;