feat(tvix/glue): Implement builtins.storePath

This one's relatively simple - we just check if the store path exists,
and if it does we make a new contextful string containing the store path
as its only context element.

Automatic testing seems tricky for this (I think?) so I tested it
manually:

tvix-repl> builtins.storePath /nix/store/yn46i4xx5alh7gs6fpkxk430i34rp2q9-hello-2.12.1
=> "/nix/store/yn46i4xx5alh7gs6fpkxk430i34rp2q9-hello-2.12.1" :: string

Change-Id: I8a0d9726e4102ab872c53c2419679c2c855a5a18
Reviewed-on: https://cl.tvl.fyi/c/depot/+/11696
Tested-by: BuildkiteCI
Autosubmit: aspen <root@gws.fyi>
Reviewed-by: flokli <flokli@flokli.de>
This commit is contained in:
Aspen Smith 2024-05-19 20:43:46 -04:00 committed by clbot
parent c3572048d5
commit 72b9a126b8
7 changed files with 62 additions and 2 deletions

View file

@ -4,7 +4,7 @@ use nix_compat::{
store_path::BuildStorePathError,
};
use reqwest::Url;
use std::rc::Rc;
use std::{path::PathBuf, rc::Rc};
use thiserror::Error;
use tvix_castore::import;
@ -65,8 +65,12 @@ pub enum FetcherError {
pub enum ImportError {
#[error("non-file '{0}' cannot be imported in 'flat' mode")]
FlatImportOfNonFile(String),
#[error("hash mismatch at ingestion of '{0}', expected: '{1}', got: '{2}'")]
HashMismatch(String, NixHash, NixHash),
#[error("path '{}' is not in the Nix store", .0.display())]
PathNotInStore(PathBuf),
}
impl From<ImportError> for tvix_eval::ErrorKind {