Skip to main content

snix_glue/
lib.rs

1#![cfg_attr(docsrs, feature(doc_cfg))]
2
3pub mod builtins;
4pub mod snix_io;
5pub mod snix_store_io;
6
7mod fetchurl;
8
9#[cfg(test)]
10mod tests;
11
12/// Tell the Evaluator to resolve `<nix>` to the path `/__corepkgs__`,
13/// which has special handling in [snix_io::SnixIO].
14/// This is used in nixpkgs to import `fetchurl.nix` from `<nix>`.
15pub fn configure_nix_path<'co, 'ro, 'env, IO>(
16    eval_builder: snix_eval::EvaluationBuilder<'co, 'ro, 'env, IO>,
17    nix_search_path: &Option<String>,
18) -> snix_eval::EvaluationBuilder<'co, 'ro, 'env, IO> {
19    eval_builder.nix_path(
20        nix_search_path
21            .as_ref()
22            .map(|p| format!("nix=/__corepkgs__:{p}"))
23            .or_else(|| Some("nix=/__corepkgs__".to_string())),
24    )
25}