snix_glue/
lib.rs

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