pub struct ChannelsFile { /* private fields */ }Implementations§
Source§impl ChannelsFile
impl ChannelsFile
Sourcepub fn parse(src: &str) -> Result<Self, Error>
pub fn parse(src: &str) -> Result<Self, Error>
Finds the first top-level list/cons/cons* form (preamble
forms like use-modules are skipped) or a bare
%default-channels symbol.
Examples found in repository?
examples/format_demo.rs (line 27)
4fn main() {
5 let os = OsBuilder::new(
6 OsFlavor::Panther,
7 "panther-box",
8 "Europe/Berlin",
9 "en_US.utf8",
10 )
11 .keyboard_layout("us", None)
12 .bootloader_efi("/boot/efi")
13 .file_system("/", FsDevice::Label("my-root".into()), "ext4", false)
14 .file_system(
15 "/boot/efi",
16 FsDevice::UuidWithType("ABCD-1234".into(), "fat32".into()),
17 "vfat",
18 false,
19 )
20 .user("panther", "panther's account", &["wheel", "audio", "video"])
21 .packages_field("%os-desktop-packages")
22 .services_field("%os-desktop-services")
23 .extra_field("swap-devices", "(list (swap-space (target \"/swapfile\")))")
24 .build();
25 println!("=== system.scm ===\n{os}");
26
27 let mut cf = ChannelsFile::parse("%default-channels").unwrap();
28 cf.add_channel(&Channel {
29 name: "pantherx".into(),
30 url: "https://codeberg.org/gofranz/panther.git".into(),
31 branch: Some("master".into()),
32 commit: None,
33 introduction_commit: Some("54b4056ac571611892c743b65f4c47dc298c49da".into()),
34 introduction_fingerprint: Some("A36A D41E ECC7 A871 1003 5D24 524F EB1A 9D33 C9CB".into()),
35 })
36 .unwrap();
37 println!("=== channels.scm (from bare %default-channels) ===\n{cf}");
38
39 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";
40 let mut cf2 = ChannelsFile::parse(src).unwrap();
41 cf2.add_channel(&Channel {
42 name: "nonguix".into(),
43 url: "https://gitlab.com/nonguix/nonguix".into(),
44 branch: None,
45 commit: None,
46 introduction_commit: Some("897c1a470da759236cc11798f4e0a5f7d4d59fbc".into()),
47 introduction_fingerprint: Some("2A39 3FFF 68F4 EF7A 3D29 12AF 6F51 20A0 22FB B2D5".into()),
48 })
49 .unwrap();
50 println!("=== channels.scm (appended to commented list) ===\n{cf2}");
51}pub fn shape(&self) -> ChannelsShape
Sourcepub fn channels(&self) -> Vec<Channel>
pub fn channels(&self) -> Vec<Channel>
The channels enumerated in the file (defaults stay implicit).
Sourcepub fn add_channel(&mut self, ch: &Channel) -> Result<(), Error>
pub fn add_channel(&mut self, ch: &Channel) -> Result<(), Error>
Append (Explicit) or insert before the %default-channels tail
(WithDefaults). A cons head is promoted to cons*.
Examples found in repository?
examples/format_demo.rs (lines 28-35)
4fn main() {
5 let os = OsBuilder::new(
6 OsFlavor::Panther,
7 "panther-box",
8 "Europe/Berlin",
9 "en_US.utf8",
10 )
11 .keyboard_layout("us", None)
12 .bootloader_efi("/boot/efi")
13 .file_system("/", FsDevice::Label("my-root".into()), "ext4", false)
14 .file_system(
15 "/boot/efi",
16 FsDevice::UuidWithType("ABCD-1234".into(), "fat32".into()),
17 "vfat",
18 false,
19 )
20 .user("panther", "panther's account", &["wheel", "audio", "video"])
21 .packages_field("%os-desktop-packages")
22 .services_field("%os-desktop-services")
23 .extra_field("swap-devices", "(list (swap-space (target \"/swapfile\")))")
24 .build();
25 println!("=== system.scm ===\n{os}");
26
27 let mut cf = ChannelsFile::parse("%default-channels").unwrap();
28 cf.add_channel(&Channel {
29 name: "pantherx".into(),
30 url: "https://codeberg.org/gofranz/panther.git".into(),
31 branch: Some("master".into()),
32 commit: None,
33 introduction_commit: Some("54b4056ac571611892c743b65f4c47dc298c49da".into()),
34 introduction_fingerprint: Some("A36A D41E ECC7 A871 1003 5D24 524F EB1A 9D33 C9CB".into()),
35 })
36 .unwrap();
37 println!("=== channels.scm (from bare %default-channels) ===\n{cf}");
38
39 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";
40 let mut cf2 = ChannelsFile::parse(src).unwrap();
41 cf2.add_channel(&Channel {
42 name: "nonguix".into(),
43 url: "https://gitlab.com/nonguix/nonguix".into(),
44 branch: None,
45 commit: None,
46 introduction_commit: Some("897c1a470da759236cc11798f4e0a5f7d4d59fbc".into()),
47 introduction_fingerprint: Some("2A39 3FFF 68F4 EF7A 3D29 12AF 6F51 20A0 22FB B2D5".into()),
48 })
49 .unwrap();
50 println!("=== channels.scm (appended to commented list) ===\n{cf2}");
51}Trait Implementations§
Source§impl Debug for ChannelsFile
impl Debug for ChannelsFile
Auto Trait Implementations§
impl Freeze for ChannelsFile
impl RefUnwindSafe for ChannelsFile
impl Send for ChannelsFile
impl Sync for ChannelsFile
impl Unpin for ChannelsFile
impl UnsafeUnpin for ChannelsFile
impl UnwindSafe for ChannelsFile
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more