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
7/// Tell the Evaluator to resolve `<nix>` to the path `/__corepkgs__`,
8/// which has special handling in [snix_io::SnixIO].
9/// This is used in nixpkgs to import `fetchurl.nix` from `<nix>`.
10pub fn configure_nix_path<'co, 'ro, 'env, IO>(
11    eval_builder: snix_eval::EvaluationBuilder<'co, 'ro, 'env, IO>,
12    nix_search_path: &Option<String>,
13) -> snix_eval::EvaluationBuilder<'co, 'ro, 'env, IO> {
14    eval_builder.nix_path(
15        nix_search_path
16            .as_ref()
17            .map(|p| format!("nix=/__corepkgs__:{p}"))
18            .or_else(|| Some("nix=/__corepkgs__".to_string())),
19    )
20}