This commit is contained in:
JMARyA 2024-12-28 00:33:50 +01:00
parent 71318a555a
commit 73a30e4576
Signed by: jmarya
GPG key ID: 901B2ADDF27C2263
4 changed files with 48 additions and 45 deletions

View file

@ -6,16 +6,31 @@ root = "/dev/null"
[general] [general]
# Use LUKS encryption on root drive # Use LUKS encryption on root drive
encryption = true encryption = true
# Preset # Preset
mode = "Desktop" mode = "Desktop"
# System Locale # System Locale
locale = "de_DE.UTF-8" locale = "de_DE.UTF-8"
# Keymap
keymap = "de-latin1"
# Timezone
timezone = "Europe/Berlin"
# Hostname
hostname = "navos"
[pkg]
# Additional packages # Additional packages
pkg = [ pkg = [
"nano", "nano",
"micro" "micro"
] ]
# Enable virtualization # Enable virtualization
virtualization = true virtualization = true
# Enable docker # Enable docker
docker = true docker = true

View file

@ -7,6 +7,18 @@ pub struct InstallConfig {
pub drive: DriveConfig, pub drive: DriveConfig,
/// General Configuration /// General Configuration
pub general: GeneralConfig, pub general: GeneralConfig,
/// Package Configuration
pub pkg: PackageConfig
}
#[derive(Debug, Deserialize)]
pub struct PackageConfig {
/// Packages to install
pub pkg: Vec<String>,
/// Enable libvirt
pub virtualization: bool,
/// Enable docker
pub docker: bool,
} }
#[derive(Debug, Deserialize)] #[derive(Debug, Deserialize)]
@ -31,12 +43,6 @@ pub struct GeneralConfig {
pub timezone: String, pub timezone: String,
/// Hostname /// Hostname
pub hostname: String, pub hostname: String,
/// Packages to install
pub pkg: Vec<String>,
/// Enable libvirt
pub virtualization: bool,
/// Enable docker
pub docker: bool,
} }
#[derive(Debug, Deserialize)] #[derive(Debug, Deserialize)]

View file

@ -2,12 +2,14 @@
// TODO : Setup ssh (config + authorized_keys) // TODO : Setup ssh (config + authorized_keys)
// TODO : Setup virtualization // TODO : Setup virtualization
// TODO : Setup docker // TODO : Setup docker
// TODO : Autojoin docker swarm
// TODO : Autojoin teleport
// DRIVE SELECTION // DRIVE SELECTION
use crate::{ use crate::{
config::{DriveConfig, GeneralConfig, InstallConfig}, config::{DriveConfig, GeneralConfig, InstallConfig, PackageConfig},
pkg, run_command, pkg, pkg::install_pkgs, run_command,
}; };
pub fn str_vec(v: Vec<&str>) -> Vec<String> { pub fn str_vec(v: Vec<&str>) -> Vec<String> {
@ -67,7 +69,7 @@ pub fn mount_drives(conf: &DriveConfig, encrypted: bool) {
// PACSTRAP // PACSTRAP
pub fn pacstrap(conf: &GeneralConfig) { pub fn pacstrap(conf: &PackageConfig) {
let mut cmd: Vec<String> = vec![ let mut cmd: Vec<String> = vec![
"pacstrap".into(), "pacstrap".into(),
"-K".into(), "-K".into(),
@ -157,18 +159,7 @@ pub fn uncomment_first_value_of(value: &str, file: &str) {
} }
pub fn setup_zram() { pub fn setup_zram() {
run_command( install_pkgs(&["zram-generator"]);
&str_vec(vec![
"arch-chroot",
"/mnt",
"pacman",
"-Syu",
"--noconfirm",
"zram-generator",
]),
None,
false,
);
std::fs::write( std::fs::write(
"/mnt/etc/systemd/zram-generator.conf", "/mnt/etc/systemd/zram-generator.conf",
include_str!("root/zram-generator.conf"), include_str!("root/zram-generator.conf"),
@ -282,18 +273,7 @@ pub fn setup_secure_boot() {
// TPM Unlock // TPM Unlock
pub fn setup_tpm_unlock(conf: &DriveConfig) { pub fn setup_tpm_unlock(conf: &DriveConfig) {
run_command( install_pkgs(&["tpm2-tools"]);
&str_vec(vec![
"arch-chroot",
"/mnt",
"pacman",
"-Syu",
"--noconfirm",
"tpm2-tools",
]),
None,
false,
);
// systemd-cryptenroll --tpm2-device=list // 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() { pub fn setup_bootloader() {
run_command( run_command(
&str_vec(vec!["arch-chroot", "/mnt", "bootctl", "install"]), &str_vec(vec!["arch-chroot", "/mnt", "bootctl", "install"]),
@ -347,7 +318,7 @@ pub fn install(conf: InstallConfig) {
mount_drives(&conf.drive, conf.general.encryption); mount_drives(&conf.drive, conf.general.encryption);
// Base Install // Base Install
pacstrap(&conf.general); pacstrap(&conf.pkg);
genfstab(); genfstab();
// System Setup // System Setup
@ -367,11 +338,11 @@ pub fn install(conf: InstallConfig) {
} }
} }
if conf.general.virtualization { if conf.pkg.virtualization {
// TODO : Enable virtualization // TODO : Enable virtualization
} }
if conf.general.docker { if conf.pkg.docker {
// TODO : Enable docker // TODO : Enable docker
} }

View file

@ -1,3 +1,14 @@
use crate::{install::str_vec, run_command};
pub const DESKTOP_PKG: [&str; 2] = ["plasma", "sddm"]; pub const DESKTOP_PKG: [&str; 2] = ["plasma", "sddm"];
pub const SERVER_PKG: [&str; 1] = ["tmux"]; 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);
}