navinstall/src/config.rs
JMARyA 633a0ef410
All checks were successful
ci/woodpecker/push/build Pipeline was successful
add docker support
2025-01-05 05:15:14 +01:00

110 lines
2.5 KiB
Rust

use std::fmt::Display;
use serde::Deserialize;
/// 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 doas_root: Option<bool>,
pub docker: 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 {
/// Boot Drive Path
pub boot: String,
/// Root Drive Path
pub root: String,
/// Enable encryption on root
pub encryption: Option<String>,
}
#[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>,
}
#[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(())
}
}