guix-scheme
Read/write Guix Scheme files from Rust: parse and edit channels.scm without losing comments or formatting, and generate operating-system configurations. Built on a lossless S-expression concrete syntax tree, so untouched parts of a file survive edits byte-for-byte.
Editing channels.scm
use ;
let src = read_to_string?;
let mut cf = parse?;
cf.add_channel?;
cf.remove_channel?;
write?;
Comments, indentation, and everything you didn't touch come back byte-identical.
A note on what this is (and isn't)
Parsing Guix Scheme from Rust is not ideal, and this crate cannot validate content. It's a poor man's workaround for when Guix isn't available, or when you'd rather read and write these files from Rust. Scheme and Guix are a full language and application; guix-scheme is just a dumb parser. It won't tell you if something is missing (a module import, a required field) or otherwise wrong. If you need real validation, feed the result through Guix itself (see the guile-check feature below for a partial check).
Generating an operating-system
use ;
let config = new
.bootloader_efi
.file_system
.user
.services_field
.build;
Feature flags
guile-check(guix-scheme): validate generated/edited source by feeding it through a realguilereader. Off by default; requiresguileonPATHat runtime.
MSRV
Rust 1.70 (2021 edition). Verified to build on 1.70; also tested on current stable.
Fixture sources
The test corpus (35 files under scheme-edit/tests/fixtures/) is copied verbatim
from GNU Guix, libguix, guix-install, and community configuration repos found via
awesome-guix. Each file keeps its
original copyright and license. Full credits:
scheme-edit/tests/fixtures/SOURCES.md.
License
Licensed under either of MIT or Apache-2.0 at your option.