guix-scheme 0.2.0

Read, edit, and generate Guix Scheme files (channels.scm, system config.scm) from Rust
Documentation
//! Read, edit, and generate Guix Scheme files (channels.scm, system config.scm) from Rust.
//!
//! ```
//! use guix_scheme::{Channel, ChannelsFile};
//! let mut cf = ChannelsFile::parse("(list)").unwrap();
//! cf.add_channel(&Channel {
//!     name: "pantherx".into(),
//!     url: "https://codeberg.org/gofranz/panther.git".into(),
//!     branch: Some("master".into()),
//!     commit: None,
//!     introduction_commit: Some("54b4056ac571611892c743b65f4c47dc298c49da".into()),
//!     introduction_fingerprint: Some("A36A D41E ECC7 A871 1003  5D24 524F EB1A 9D33 C9CB".into()),
//! }).unwrap();
//! assert!(cf.to_string().contains("(name 'pantherx)"));
//! ```
//!
//! # Boundaries
//!
//! String in, string out: this crate parses `&str` and renders back to
//! `String`, and does no file IO. Reading files, writing them atomically,
//! keeping backups, and refusing symlinks or store-managed paths are the
//! caller's job.
//!
//! Edits are byte-preserving. Running on a lossless CST (see `scheme-edit`),
//! adding or removing a channel keeps every untouched byte and comment intact
//! and only formats the node it inserts, instead of reflowing the whole file.

mod channel;
mod channels_file;
mod error;
#[cfg(feature = "guile-check")]
pub mod guile_check;
pub mod module;
pub mod os_builder;
pub mod os_view;
pub mod record;
pub mod services;
pub mod validate;

pub use channel::Channel;
pub use channels_file::{ChannelsFile, ChannelsShape};
pub use error::Error;
pub use module::{ModuleFile, PackageView, PackageViewMut, RecordFieldView, RecordTypeView};
pub use os_view::{OperatingSystemView, OperatingSystemViewMut};
pub use services::{ServicesView, ServicesViewMut};

/// Cheap syntax check: `Ok(())` iff SRC parses as Scheme.
///
/// This only verifies the surface syntax (balanced delimiters, valid
/// tokens); it does not evaluate the form or resolve any Guix bindings.
/// For a deeper check that actually loads the config, enable the
/// `guile-check` feature.
pub fn validate_syntax(src: &str) -> Result<(), Error> {
    scheme_edit::Document::parse(src)?;
    Ok(())
}