use std::fmt::Write; pub struct Initcpio { encrypted: bool, plymouth: bool, } impl Initcpio { pub fn new(encrypted: bool, plymouth: bool) -> Self { Self { encrypted, plymouth, } } pub fn to_config(&self) -> anyhow::Result { let mut output = String::from( "MODULES=() BINARIES=() FILES=() HOOKS=(base udev autodetect modconf kms keyboard keymap consolefont block ", ); if self.encrypted { output.write_str("encrypt ")?; } if self.plymouth { output.write_str("filesystems plymouth)\n")?; } else { output.write_str("filesystems fsck)\n")?; } Ok(output) } }