diff --git a/src/install/first_boot.rs b/src/install/first_boot.rs index 93dcf4f..6085b23 100644 --- a/src/install/first_boot.rs +++ b/src/install/first_boot.rs @@ -35,6 +35,7 @@ pub fn first_boot_values(conf: &GeneralConfig) { } std::os::unix::fs::symlink(tz_link, "/mnt/etc/localtime").unwrap(); + arch_chroot(&["hwclock", "--systohc"], None, false); // Keymap print_status("Writing /etc/vconsole.conf"); @@ -49,8 +50,6 @@ pub fn first_boot_values(conf: &GeneralConfig) { uncomment_first_value_of(&conf.locale, "/mnt/etc/locale.gen"); arch_chroot(&["locale-gen"], None, false); - arch_chroot(&["hwclock", "--systohc"], None, false); - if let Some(root_pw) = &conf.root_password { change_passwd("root", root_pw); } diff --git a/src/install/kernel.rs b/src/install/kernel.rs index 5e27c7e..c71c69b 100644 --- a/src/install/kernel.rs +++ b/src/install/kernel.rs @@ -26,7 +26,6 @@ pub fn setup_mkinitcpio(conf: &DriveConfig) { std::fs::write("/mnt/etc/kernel/cmdline", format!("root={}", conf.root)).unwrap(); } - // TODO : more configs print_status("Writing /etc/mkinitcpio.conf"); install_file( "/mnt/etc/mkinitcpio.conf", diff --git a/src/install/mod.rs b/src/install/mod.rs index 1cc1ed5..228483e 100644 --- a/src/install/mod.rs +++ b/src/install/mod.rs @@ -76,6 +76,7 @@ pub fn uncomment_tag(tag: &str, file: &str) { std::fs::write(file, new).unwrap(); } +/// Install a config on a new system pub fn install(conf: InstallConfig) { // Drive Setup format_drives(&conf.drive); diff --git a/src/main.rs b/src/main.rs index fae07a6..bdf8902 100644 --- a/src/main.rs +++ b/src/main.rs @@ -50,25 +50,7 @@ fn main() { } Some(("create-img", install_args)) => { let config_file: &String = install_args.get_one("config").unwrap(); - let config_content = std::fs::read_to_string(config_file); - - let conf: InstallConfig = match config_content { - Ok(content) => match toml::from_str(&content) { - Ok(config) => config, - Err(e) => { - eprintln!( - "{} {}", - "Error: Could not deserialize TOML file.".paint(Color::Red), - e.paint(Color::Red) - ); - std::process::exit(1); - } - }, - Err(_) => { - eprintln!("{}", "Error: Could not read config file.".paint(Color::Red)); - std::process::exit(1); - } - }; + let conf = read_conf(config_file); println!("Installing to a disk image is not yet supported"); unimplemented!() @@ -81,25 +63,7 @@ fn main() { let config_file: &String = install_args.get_one("config").unwrap(); let force = install_args.get_flag("force"); - let config_content = std::fs::read_to_string(config_file); - - let conf: InstallConfig = match config_content { - Ok(content) => match toml::from_str(&content) { - Ok(config) => config, - Err(e) => { - eprintln!( - "{} {}", - "Error: Could not deserialize TOML file.".paint(Color::Red), - e.paint(Color::Red) - ); - std::process::exit(1); - } - }, - Err(_) => { - eprintln!("{}", "Error: Could not read config file.".paint(Color::Red)); - std::process::exit(1); - } - }; + let conf = read_conf(config_file); if !force { print_config(&conf); @@ -128,3 +92,25 @@ pub fn expect_yes() { std::process::exit(0); } } + +pub fn read_conf(config_file: &str) -> InstallConfig { + let config_content = std::fs::read_to_string(config_file); + + match config_content { + Ok(content) => match toml::from_str(&content) { + Ok(config) => config, + Err(e) => { + eprintln!( + "{} {}", + "Error: Could not deserialize TOML file.".paint(Color::Red), + e.paint(Color::Red) + ); + std::process::exit(1); + } + }, + Err(_) => { + eprintln!("{}", "Error: Could not read config file.".paint(Color::Red)); + std::process::exit(1); + } + } +} \ No newline at end of file diff --git a/src/print.rs b/src/print.rs index 139c5ce..24cf4e1 100644 --- a/src/print.rs +++ b/src/print.rs @@ -145,7 +145,7 @@ pub fn print_config(conf: &InstallConfig) { } if let Some(models) = &ai_conf.models { - ai_info.add_str(format!("⬇️ Pull Models: {}", models.join(", "))); + ai_info.add_str(format!("⬇️ Pull Models: {}", models.join(", "))); } root_info.add_tree("🦙 Ollama", ai_info);