feat(tvix/glue): handle regular file at builtins.path import

If builtins.path is passed a regular file, no filtering is applied.
We use the just-introduced file_type function in the EvalIO trait for
that.

This means, we don't need to pass through filtered_ingest, and can
assemble the FileNode directly in that specific match case.

This also means, we can explicitly calculate the sha256 flat digest,
and avoid having to pipe through the file contents again (via
blob_to_sha256_hash) to construct the sha256 digest.

Change-Id: I500b19dd9e4b7cc897d88b44547e7851559e5a4e
Reviewed-on: https://cl.tvl.fyi/c/depot/+/11872
Tested-by: BuildkiteCI
Reviewed-by: Ilan Joselevich <personal@ilanjoselevich.com>
Reviewed-by: Connor Brewster <cbrewster@hey.com>
This commit is contained in:
Florian Klink 2024-06-25 19:40:55 +03:00 committed by flokli
parent 080654aaf9
commit 78eb22c54d
3 changed files with 114 additions and 72 deletions

View file

@ -127,15 +127,6 @@ Some more fetcher-related builtins need work:
- `fetchTree` (hairy, seems there's no proper spec and the URL syntax seems
subject to change/underdocumented)
### `builtins.path` roundtrip for flat
`builtins.path` currently uses `filtered_ingest` also for the non-recursive
case, then reads through the blob contents again to get the sha256.
We should take care of assembling the root node on our own, and pipe the data
through sha256 too (via `InspectReader`, see `glue/fetcher` for an example).
This avoids some roundtrips, and is probably faster.
### Derivation -> Build
While we have some support for `structuredAttrs` and `fetchClosure` (at least
enough to calculate output hashes, aka produce identical ATerm), the code