2023-11-03 16:40:32 +02:00
|
|
|
pub mod builtins;
|
refactor(tvix/glue): move Fetch[er] into its own types, fetch lazily
We actually want to delay fetching until we actually need the file. A
simple evaluation asking for `.outPath` or `.drvPath` should work even
in a pure offline environment.
Before this CL, the fetching logic was quite distributed between
tvix_store_io, and builtins/fetchers.rs.
Rather than having various functions and conversions between structs,
describe a Fetch as an enum type, with the fields describing the fetch.
Define a store_path() function on top of `Fetch` which can be used to
ask for the calculated store path (if the digest has been provided
upfront).
Have a `Fetcher` struct, and give it a `fetch_and_persist` function,
taking a `Fetch` as well as a desired name, and have it deal with all
the logic of persisting the PathInfos. It also returns a StorePathRef,
similar to the `.store_path()` method on a `Fetch` struct.
In a followup CL, we can extend KnownPaths to track fetches AND
derivations, and then use `Fetcher` when we need to do IO into that
store path.
Change-Id: Ib39a96baeb661750a8706b461f8ba4abb342e777
Reviewed-on: https://cl.tvl.fyi/c/depot/+/11500
Reviewed-by: raitobezarius <tvl@lahfa.xyz>
Autosubmit: flokli <flokli@flokli.de>
Tested-by: BuildkiteCI
2024-04-22 14:02:48 +03:00
|
|
|
pub mod fetchers;
|
2023-11-03 13:34:37 +02:00
|
|
|
pub mod known_paths;
|
2023-12-09 12:53:17 +02:00
|
|
|
pub mod tvix_build;
|
2023-11-03 13:34:37 +02:00
|
|
|
pub mod tvix_io;
|
|
|
|
pub mod tvix_store_io;
|
|
|
|
|
2024-02-19 22:20:09 +07:00
|
|
|
mod fetchurl;
|
|
|
|
|
2024-11-28 21:21:01 +02:00
|
|
|
// Used as user agent in various HTTP Clients
|
|
|
|
const USER_AGENT: &str = concat!(env!("CARGO_PKG_NAME"), "/", env!("CARGO_PKG_VERSION"));
|
|
|
|
|
2024-01-14 01:41:16 +01:00
|
|
|
#[cfg(test)]
|
|
|
|
mod tests;
|
|
|
|
|
2023-12-21 17:25:22 +02:00
|
|
|
/// Tell the Evaluator to resolve `<nix>` to the path `/__corepkgs__`,
|
2023-11-03 14:03:19 +02:00
|
|
|
/// which has special handling in [tvix_io::TvixIO].
|
|
|
|
/// This is used in nixpkgs to import `fetchurl.nix` from `<nix>`.
|
2024-07-05 20:29:41 -04:00
|
|
|
pub fn configure_nix_path<'co, 'ro, 'env, IO>(
|
|
|
|
eval_builder: tvix_eval::EvaluationBuilder<'co, 'ro, 'env, IO>,
|
2024-01-16 14:19:16 +02:00
|
|
|
nix_search_path: &Option<String>,
|
2024-07-05 20:29:41 -04:00
|
|
|
) -> tvix_eval::EvaluationBuilder<'co, 'ro, 'env, IO> {
|
|
|
|
eval_builder.nix_path(
|
|
|
|
nix_search_path
|
|
|
|
.as_ref()
|
|
|
|
.map(|p| format!("nix=/__corepkgs__:{}", p))
|
|
|
|
.or_else(|| Some("nix=/__corepkgs__".to_string())),
|
|
|
|
)
|
2023-11-03 14:03:19 +02:00
|
|
|
}
|