guix-scheme 0.2.0

Read, edit, and generate Guix Scheme files (channels.scm, system config.scm) from Rust
Documentation
use guix_scheme::os_builder::{FsDevice, OsBuilder, OsFlavor};
use guix_scheme::{Channel, ChannelsFile};

fn main() {
    let os = OsBuilder::new(
        OsFlavor::Panther,
        "panther-box",
        "Europe/Berlin",
        "en_US.utf8",
    )
    .keyboard_layout("us", None)
    .bootloader_efi("/boot/efi")
    .file_system("/", FsDevice::Label("my-root".into()), "ext4", false)
    .file_system(
        "/boot/efi",
        FsDevice::UuidWithType("ABCD-1234".into(), "fat32".into()),
        "vfat",
        false,
    )
    .user("panther", "panther's account", &["wheel", "audio", "video"])
    .packages_field("%os-desktop-packages")
    .services_field("%os-desktop-services")
    .extra_field("swap-devices", "(list (swap-space (target \"/swapfile\")))")
    .build();
    println!("=== system.scm ===\n{os}");

    let mut cf = ChannelsFile::parse("%default-channels").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();
    println!("=== channels.scm (from bare %default-channels) ===\n{cf}");

    let src = ";; my channels\n(list\n ;; the guix channel\n (channel\n  (name 'guix)\n  (url \"https://git.savannah.gnu.org/git/guix.git\")))\n";
    let mut cf2 = ChannelsFile::parse(src).unwrap();
    cf2.add_channel(&Channel {
        name: "nonguix".into(),
        url: "https://gitlab.com/nonguix/nonguix".into(),
        branch: None,
        commit: None,
        introduction_commit: Some("897c1a470da759236cc11798f4e0a5f7d4d59fbc".into()),
        introduction_fingerprint: Some("2A39 3FFF 68F4 EF7A 3D29  12AF 6F51 20A0 22FB B2D5".into()),
    })
    .unwrap();
    println!("=== channels.scm (appended to commented list) ===\n{cf2}");
}