diff --git a/installs/testinstall.toml b/installs/testinstall.toml index 266262f..fa67907 100644 --- a/installs/testinstall.toml +++ b/installs/testinstall.toml @@ -6,16 +6,31 @@ root = "/dev/null" [general] # Use LUKS encryption on root drive encryption = true + # Preset mode = "Desktop" + # System Locale locale = "de_DE.UTF-8" + +# Keymap +keymap = "de-latin1" + +# Timezone +timezone = "Europe/Berlin" + +# Hostname +hostname = "navos" + +[pkg] # Additional packages pkg = [ "nano", "micro" ] + # Enable virtualization virtualization = true + # Enable docker docker = true diff --git a/src/config.rs b/src/config.rs index 39e01e1..6259a32 100644 --- a/src/config.rs +++ b/src/config.rs @@ -7,6 +7,18 @@ pub struct InstallConfig { pub drive: DriveConfig, /// General Configuration pub general: GeneralConfig, + /// Package Configuration + pub pkg: PackageConfig +} + +#[derive(Debug, Deserialize)] +pub struct PackageConfig { + /// Packages to install + pub pkg: Vec, + /// Enable libvirt + pub virtualization: bool, + /// Enable docker + pub docker: bool, } #[derive(Debug, Deserialize)] @@ -31,12 +43,6 @@ pub struct GeneralConfig { pub timezone: String, /// Hostname pub hostname: String, - /// Packages to install - pub pkg: Vec, - /// Enable libvirt - pub virtualization: bool, - /// Enable docker - pub docker: bool, } #[derive(Debug, Deserialize)] diff --git a/src/install.rs b/src/install.rs index bc75d78..bd4f92b 100644 --- a/src/install.rs +++ b/src/install.rs @@ -2,12 +2,14 @@ // TODO : Setup ssh (config + authorized_keys) // TODO : Setup virtualization // TODO : Setup docker +// TODO : Autojoin docker swarm +// TODO : Autojoin teleport // DRIVE SELECTION use crate::{ - config::{DriveConfig, GeneralConfig, InstallConfig}, - pkg, run_command, + config::{DriveConfig, GeneralConfig, InstallConfig, PackageConfig}, + pkg, pkg::install_pkgs, run_command, }; pub fn str_vec(v: Vec<&str>) -> Vec { @@ -67,7 +69,7 @@ pub fn mount_drives(conf: &DriveConfig, encrypted: bool) { // PACSTRAP -pub fn pacstrap(conf: &GeneralConfig) { +pub fn pacstrap(conf: &PackageConfig) { let mut cmd: Vec = vec![ "pacstrap".into(), "-K".into(), @@ -157,18 +159,7 @@ pub fn uncomment_first_value_of(value: &str, file: &str) { } pub fn setup_zram() { - run_command( - &str_vec(vec![ - "arch-chroot", - "/mnt", - "pacman", - "-Syu", - "--noconfirm", - "zram-generator", - ]), - None, - false, - ); + install_pkgs(&["zram-generator"]); std::fs::write( "/mnt/etc/systemd/zram-generator.conf", include_str!("root/zram-generator.conf"), @@ -282,18 +273,7 @@ pub fn setup_secure_boot() { // TPM Unlock pub fn setup_tpm_unlock(conf: &DriveConfig) { - run_command( - &str_vec(vec![ - "arch-chroot", - "/mnt", - "pacman", - "-Syu", - "--noconfirm", - "tpm2-tools", - ]), - None, - false, - ); + install_pkgs(&["tpm2-tools"]); // systemd-cryptenroll --tpm2-device=list @@ -324,15 +304,6 @@ pub fn setup_tpm_unlock(conf: &DriveConfig) { ); } -pub fn install_pkgs(pkg: &[&str]) { - let mut cmd = vec!["arch-chroot", "/mnt", "pacman", "-Syu"]; - - cmd.extend_from_slice(pkg); - cmd.push("--noconfirm"); - - run_command(&str_vec(cmd), None, true); -} - pub fn setup_bootloader() { run_command( &str_vec(vec!["arch-chroot", "/mnt", "bootctl", "install"]), @@ -347,7 +318,7 @@ pub fn install(conf: InstallConfig) { mount_drives(&conf.drive, conf.general.encryption); // Base Install - pacstrap(&conf.general); + pacstrap(&conf.pkg); genfstab(); // System Setup @@ -367,11 +338,11 @@ pub fn install(conf: InstallConfig) { } } - if conf.general.virtualization { + if conf.pkg.virtualization { // TODO : Enable virtualization } - if conf.general.docker { + if conf.pkg.docker { // TODO : Enable docker } diff --git a/src/pkg.rs b/src/pkg.rs index aa20e47..8c94148 100644 --- a/src/pkg.rs +++ b/src/pkg.rs @@ -1,3 +1,14 @@ +use crate::{install::str_vec, run_command}; + pub const DESKTOP_PKG: [&str; 2] = ["plasma", "sddm"]; pub const SERVER_PKG: [&str; 1] = ["tmux"]; + +pub fn install_pkgs(pkg: &[&str]) { + let mut cmd = vec!["arch-chroot", "/mnt", "pacman", "-Syu"]; + + cmd.push("--noconfirm"); + cmd.extend_from_slice(pkg); + + run_command(&str_vec(cmd), None, true); +} \ No newline at end of file