145 lines
3.4 KiB
Rust
145 lines
3.4 KiB
Rust
use std::fmt::Display;
|
|
|
|
use serde::Deserialize;
|
|
|
|
use crate::install::drives::partition_disk;
|
|
|
|
/// Declarative install configuration
|
|
#[derive(Debug, Clone, Deserialize)]
|
|
pub struct InstallConfig {
|
|
/// Drive Configuration
|
|
pub drive: DriveConfig,
|
|
/// General Configuration
|
|
pub general: GeneralConfig,
|
|
/// Package Configuration
|
|
pub pkg: PackageConfig,
|
|
/// User Configuration
|
|
pub user: Option<Vec<UserConfig>>,
|
|
/// SSH Configuration
|
|
pub ssh: Option<SSHConfig>,
|
|
/// Ollama AI Config
|
|
pub ai: Option<OllamaConfig>,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Deserialize)]
|
|
pub struct OllamaConfig {
|
|
pub models: Option<Vec<String>>,
|
|
pub gpu: bool,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Deserialize)]
|
|
pub struct SSHConfig {
|
|
pub sshd_config: Option<String>,
|
|
pub key: Option<Vec<SSHKey>>,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Deserialize)]
|
|
pub struct SSHKey {
|
|
pub key: String,
|
|
pub users: Vec<String>,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Deserialize)]
|
|
pub struct UserConfig {
|
|
pub name: String,
|
|
pub password: String,
|
|
pub uid: Option<u32>,
|
|
pub home_dir: Option<String>,
|
|
pub shell: Option<String>,
|
|
pub wheel: Option<bool>,
|
|
pub docker: Option<bool>,
|
|
pub virtualization: Option<bool>,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Deserialize)]
|
|
pub struct PackageConfig {
|
|
/// Packages to install
|
|
pub pkg: Vec<String>,
|
|
/// Enable libvirt
|
|
pub virtualization: Option<bool>,
|
|
/// Enable docker
|
|
pub docker: Option<bool>,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Deserialize)]
|
|
pub struct DriveConfig {
|
|
/// Disk Path (using entire disk)
|
|
pub disk: Option<String>,
|
|
/// Boot Drive Path
|
|
pub boot: Option<String>,
|
|
/// Root Drive Path
|
|
pub root: Option<String>,
|
|
/// Enable encryption on root
|
|
pub encryption: Option<String>,
|
|
}
|
|
|
|
impl DriveConfig {
|
|
pub fn use_entire_disk(&mut self) {
|
|
if self.disk.is_some() {
|
|
partition_disk(&self.disk.as_ref().unwrap());
|
|
|
|
// TODO : assign two children to root / boot the right way
|
|
self.boot = Some(format!("{}1", self.disk.as_ref().unwrap()));
|
|
self.root = Some(format!("{}2", self.disk.as_ref().unwrap()));
|
|
}
|
|
}
|
|
}
|
|
|
|
#[derive(Debug, Clone, Deserialize)]
|
|
pub struct GeneralConfig {
|
|
/// Presets
|
|
pub mode: InstallMode,
|
|
/// System locale
|
|
pub locale: String,
|
|
/// Keyboard Layout
|
|
pub keyboard_layout: String,
|
|
/// Keyboard Variant
|
|
pub keyboard_variant: Option<String>,
|
|
/// Timezone
|
|
pub timezone: String,
|
|
/// Hostname
|
|
pub hostname: String,
|
|
// Root password
|
|
pub root_password: Option<String>,
|
|
// Enable Bluetooth
|
|
pub bluetooth: Option<bool>,
|
|
/// Install Video Driver
|
|
pub gpu_driver: Option<GPUVendor>,
|
|
// Enable firewall
|
|
pub firewall: Option<bool>,
|
|
// Want Secure Boot
|
|
pub secure_boot: Option<bool>,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Deserialize)]
|
|
pub enum GPUVendor {
|
|
AMD,
|
|
NVIDIA,
|
|
INTEL,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Deserialize)]
|
|
pub enum InstallMode {
|
|
/// Basic Arch Linux Installation
|
|
Base,
|
|
/// navOS Desktop
|
|
Desktop,
|
|
/// navOS Server
|
|
Server,
|
|
|
|
// TODO : Evaluate
|
|
Kiosk,
|
|
}
|
|
|
|
impl Display for InstallMode {
|
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
match self {
|
|
InstallMode::Base => f.write_str("Base")?,
|
|
InstallMode::Desktop => f.write_str("Desktop")?,
|
|
InstallMode::Server => f.write_str("Server")?,
|
|
InstallMode::Kiosk => f.write_str("Kiosk")?,
|
|
}
|
|
|
|
Ok(())
|
|
}
|
|
}
|