nix_flake_lock/lib.rs
1//! Fast, high-level access to Nix flake lock files.
2//!
3//! The crate parses directly into a compact indexed graph. It does not build a
4//! generic JSON tree and does not require Nix or its C++ libraries at runtime.
5//! Unescaped strings borrow from the input buffer, while canonical
6//! serialization writes directly to a caller-provided byte vector.
7//!
8//! The `0.1` API intentionally exposes a read-only graph. Use
9//! [`LockFile::into_owned`] to detach a parsed graph from its input lifetime;
10//! this does not make the graph mutable.
11//!
12//! # Example
13//!
14//! ```
15//! use nix_flake_lock::LockFile;
16//!
17//! # let bytes = include_bytes!("../tests/fixtures/tiny.lock");
18//! let lock = LockFile::parse(bytes)?;
19//! lock.validate()?;
20//! let canonical = lock.to_nix_bytes();
21//! assert_eq!(LockFile::parse(&canonical)?, lock);
22//! # Ok::<(), Box<dyn std::error::Error>>(())
23//! ```
24
25#![forbid(unsafe_code)]
26#![deny(missing_docs)]
27
28mod diff;
29mod model;
30mod parse;
31mod validate;
32mod write;
33
34pub use diff::{Change, EdgeValue};
35pub use model::{
36 Attr, AttrSet, AttrValue, Edge, Input, InputPath, LockFile, LockedNode, Node, NodeId, NodeKind,
37 OwnedLockFile,
38};
39pub use parse::{Error, ErrorKind, Limits};
40pub use validate::{ResolveError, ValidationError};