Skip to main content

Crate guix_scheme

Crate guix_scheme 

Source
Expand description

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.

Re-exports§

pub use module::ModuleFile;
pub use module::PackageView;
pub use module::PackageViewMut;
pub use module::RecordFieldView;
pub use module::RecordTypeView;
pub use os_view::OperatingSystemView;
pub use os_view::OperatingSystemViewMut;
pub use services::ServicesView;
pub use services::ServicesViewMut;

Modules§

module
Thin typed layer over guix package/service module files.
os_builder
Builder for (operating-system ...) system configurations, mirroring what guix-install renders.
os_view
Read and mutate view over an (operating-system ...) form.
record
Generic view over (record-name (field value) ...) forms.
services
Typed view over a services expression (the value of a config’s services field). Blessed shapes are edited; everything else is refused without touching the tree.
validate
Field validation ported from libguix (channels.rs), same rules and error wording so a migration is behavior-neutral.

Structs§

Channel
A guix channel as written to channels.scm.
ChannelsFile

Enums§

ChannelsShape
Top-level channels-form shape, preserved across read/edit so the user’s stylistic choice survives a round-trip.
Error

Functions§

validate_syntax
Cheap syntax check: Ok(()) iff SRC parses as Scheme.