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]
# 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

View file

@ -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<String>,
/// 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<String>,
/// Enable libvirt
pub virtualization: bool,
/// Enable docker
pub docker: bool,
}
#[derive(Debug, Deserialize)]

View file

@ -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<String> {
@ -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<String> = 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
}

View file

@ -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);
}