diff --git a/installs/desktop.toml b/installs/desktop.toml index 668bb61..75c08ce 100644 --- a/installs/desktop.toml +++ b/installs/desktop.toml @@ -36,6 +36,9 @@ root_password = "root" # Enable Bluetooth bluetooth = true +# GPU Video Drivers +gpu_driver = "NVIDIA" + [pkg] # Additional packages pkg = [ diff --git a/installs/full.toml b/installs/full.toml index dc9efe9..85e39b8 100644 --- a/installs/full.toml +++ b/installs/full.toml @@ -36,6 +36,9 @@ root_password = "root" # Enable Bluetooth bluetooth = true +# GPU Video Drivers +gpu_driver = "NVIDIA" + [pkg] # Additional packages pkg = [ diff --git a/src/config.rs b/src/config.rs index 8b37653..2b4b301 100644 --- a/src/config.rs +++ b/src/config.rs @@ -87,6 +87,15 @@ pub struct GeneralConfig { pub root_password: Option, // Enable Bluetooth pub bluetooth: Option, + /// Install Video Driver + pub gpu_driver: Option +} + +#[derive(Debug, Clone, Deserialize)] +pub enum GPUVendor { + AMD, + NVIDIA, + INTEL } #[derive(Debug, Clone, Deserialize)] diff --git a/src/install/firmware.rs b/src/install/firmware.rs new file mode 100644 index 0000000..7bbd09e --- /dev/null +++ b/src/install/firmware.rs @@ -0,0 +1,24 @@ +use crate::{linux::systemd_service_enable, pkg::install_pkgs, print_status}; + +pub fn setup_fwupd() { + print_status("Enabling firmware updates"); + install_pkgs(&["fwupd"]); + systemd_service_enable("fwupd-refresh.timer"); +} + +pub fn setup_microcode() { + print_status("Installing CPU Microcode"); + let cpuinfo = std::fs::read_to_string("/proc/cpuinfo").unwrap(); + + for line in cpuinfo.lines() { + if line.starts_with("vendor_id") { + if line.contains("GenuineIntel") { + install_pkgs(&["intel-ucode"]); + } + + if line.contains("AuthenticAMD") { + install_pkgs(&["amd-ucode"]); + } + } + } +} diff --git a/src/install/first_boot.rs b/src/install/first_boot.rs index 6085b23..d59bcf6 100644 --- a/src/install/first_boot.rs +++ b/src/install/first_boot.rs @@ -2,7 +2,7 @@ use crate::{ config::GeneralConfig, - linux::{arch_chroot, run_command, systemd_service_enable}, + linux::{arch_chroot, install_file, run_command, systemd_service_enable}, print_status, }; @@ -45,6 +45,8 @@ pub fn first_boot_values(conf: &GeneralConfig) { print_status("Writing /etc/hostname"); std::fs::write("/mnt/etc/hostname", format!("{}\n", conf.hostname)).unwrap(); + install_file("/mnt/etc/hosts", &format!("127.0.0.1 localhost\n::1 localhost\n127.0.1.1 {}\n", conf.hostname), 0o644); + // LOCALE print_status("Setting locale"); uncomment_first_value_of(&conf.locale, "/mnt/etc/locale.gen"); diff --git a/src/install/gpu.rs b/src/install/gpu.rs new file mode 100644 index 0000000..73e5cca --- /dev/null +++ b/src/install/gpu.rs @@ -0,0 +1,15 @@ +use crate::{config::GPUVendor, pkg::install_pkgs}; + +pub fn setup_video_drivers(vendor: &GPUVendor) { + match vendor { + GPUVendor::AMD => { + install_pkgs(&["xf86-video-amdgpu", "mesa", "lib32-mesa", "vulkan-radeon", "lib32-vulkan-radeon"]); + }, + GPUVendor::NVIDIA => { + install_pkgs(&["nvidia", "nvidia-utils", "lib32-nvidia-utils"]); + }, + GPUVendor::INTEL => { + install_pkgs(&["xf86-video-intel2", "mesa", "lib32-mesa", "vulkan-intel", "lib32-vulkan-intel"]); + }, + } +} diff --git a/src/install/mod.rs b/src/install/mod.rs index 3bc7d0b..3ac2c15 100644 --- a/src/install/mod.rs +++ b/src/install/mod.rs @@ -1,5 +1,6 @@ // TODO : Autojoin docker swarm // TODO : Autojoin teleport +// TODO : Firewall // DRIVE SELECTION @@ -8,7 +9,9 @@ use boot::setup_bootloader; use desktop::setup_desktop; use docker::setup_docker; use drives::{format_drives, mount_drives}; +use firmware::{setup_fwupd, setup_microcode}; use first_boot::{first_boot_values, genfstab}; +use gpu::setup_video_drivers; use kernel::setup_mkinitcpio; use navos::setup_navos; use ollama::setup_ollama; @@ -16,7 +19,7 @@ use security::{setup_secure_boot, setup_tpm_unlock}; use skel::setup_skel; use ssh::setup_ssh; use user::setup_users; -use virt::setup_virtualization; +use virt::{setup_virtualization, setup_vm}; use yansi::{Color, Paint}; use zram::setup_zram; @@ -35,6 +38,8 @@ pub mod ssh; pub mod user; pub mod virt; pub mod zram; +pub mod firmware; +pub mod gpu; use crate::{ config::InstallConfig, @@ -137,6 +142,12 @@ pub fn install(conf: InstallConfig) { setup_bluetooth(); } + setup_vm(); + if let Some(gpu_vendor) = &conf.general.gpu_driver { + setup_video_drivers(gpu_vendor); + } + setup_fwupd(); + setup_microcode(); setup_mkinitcpio(&conf.drive); setup_secure_boot(); diff --git a/src/install/virt.rs b/src/install/virt.rs index 1e1300a..78757fe 100644 --- a/src/install/virt.rs +++ b/src/install/virt.rs @@ -29,3 +29,7 @@ pub fn setup_virtualization(conf: &InstallConfig) { } } } + +pub fn setup_vm() { + // TODO : Install guest tools if in virt with systemd-detect-virt +} diff --git a/src/pkg.rs b/src/pkg.rs index 1fb60a3..479412e 100644 --- a/src/pkg.rs +++ b/src/pkg.rs @@ -3,7 +3,31 @@ use crate::{ linux::{arch_chroot, run_command}, }; -pub const DESKTOP_PKG: [&str; 5] = ["plasma", "sddm", "konsole", "dolphin", "navos/navos"]; +pub const DESKTOP_PKG: [&str; 16] = [ + // Desktop + "plasma", + "sddm", + + // Sound + "pipewire", + "pipewire-alsa", + "pipewire-pulse", + "pipewire-jack", + "wireplumber", + + // Applications + "konsole", + "dolphin", + "ffmpegthumbs", + "kate", + "okular", + "gwenview", + "ark", + "flatpak", + + // Misc + "navos/navos" +]; pub const SERVER_PKG: [&str; 2] = ["tmux", "navos/navos"]; @@ -32,7 +56,11 @@ pub fn pacstrap(conf: &PackageConfig) { "git", "networkmanager", "nano", - "doas", + "openssh", + "zsh", + "zsh-completions", + "zsh-autosuggestions", + "man" ]; cmd.extend( diff --git a/src/print.rs b/src/print.rs index 3882cc3..efa6877 100644 --- a/src/print.rs +++ b/src/print.rs @@ -63,6 +63,13 @@ pub fn print_config(conf: &InstallConfig) { if conf.general.bluetooth.unwrap_or_default() { general_info.add_str(format!("🌀 Bluetooth {}", "✔️".paint(Color::Green))); } + if let Some(vendor) = &conf.general.gpu_driver { + match vendor { + crate::config::GPUVendor::AMD => general_info.add_str(format!("🟥 AMD GPU {}", "✔️".paint(Color::Green))), + crate::config::GPUVendor::INTEL => general_info.add_str(format!("🟦 Intel GPU {}", "✔️".paint(Color::Green))), + crate::config::GPUVendor::NVIDIA => general_info.add_str(format!("🟩 NVIDIA GPU {}", "✔️".paint(Color::Green))), + } + } root_info.add_tree("🔨 General", general_info);