nix_compat/
lib.rs

1#![cfg_attr(docsrs, feature(doc_cfg))]
2
3extern crate self as nix_compat;
4
5/// Hashes formatted string data with SHA-256, without an intermediate buffer.
6/// Analogous to [`std::fmt::format`].
7pub(crate) fn sha256_fmt(fmt: std::fmt::Arguments<'_>) -> [u8; 32] {
8    use sha2::Digest;
9    use std::io::Write;
10    let mut w = sha2::Sha256::new();
11    write!(&mut w, "{fmt}").unwrap();
12    w.finalize().into()
13}
14
15/// Analogous to [`std::format`], but returning only the SHA-256 digest of the formatted string.
16macro_rules! sha256 {
17    ($($args:tt)*) => {
18        $crate::sha256_fmt(format_args!($($args)*))
19    };
20}
21
22pub(crate) mod aterm;
23pub mod derivation;
24pub mod log;
25pub mod nar;
26pub mod narinfo;
27pub mod nix_http;
28pub mod nixbase32;
29pub mod nixcpp;
30pub mod nixhash;
31pub mod path_info;
32pub mod store_path;
33
34#[cfg(feature = "wire")]
35pub mod wire;
36
37#[cfg(feature = "daemon")]
38pub mod nix_daemon;
39#[cfg(feature = "daemon")]
40pub use nix_daemon::worker_protocol;
41#[cfg(feature = "flakeref")]
42pub mod flakeref;