Add install base and kernels step

main^2
trivernis 1 year ago
parent 7963bafed9
commit 2b7ffea75e
Signed by: Trivernis
GPG Key ID: DFFFCC2C7A02DB45

@ -46,10 +46,10 @@ module auto_partition {
run btrfs subvolume create @home
}
run umount $root_part
run mount $root_part /mnt subvol=@
run mount $root_part /mnt -o subvol=@
mkdir /mnt/boot/efi
mkdir /mnt/home
run mount $root_part /mnt/home subvol=@home
run mount $root_part /mnt/home -o subvol=@home
run mount $boot_part /mnt/boot/efi
}

@ -1,4 +1,64 @@
def install_base_packages [] {
(
run pacstrap /mnt
base
linux-firmware
systemd-sysvcompat
networkmanager
man-db
man-pages
texinfo
nano
sudo
curl
archlinux-keyring
# crystal base
crystal-core
crystal-branding
# crystal extras
crystal-first-setup
neofetch
btrfs-progs
which
base-devel
# fonts
noto-fonts
noto-fonts-emoji
noto-fonts-cjk
noto-fonts-extra
ttf-nerd-fonts-symbols-common
ttf-firacode-nerd
ttf-liberation
# audio
pipewire
pipewire-pulse
pipewire-alsa
pipewire-jack
wireplumber
helvum
# utils
xterm
cups
cups-pdf
bluez
bluez-cups
ntfs-3g
bash-completion
zsh-completions
)
}
# Applies all system changes of `install-base`
def main [cfg] {
echo "Executing up task `install-base` with config" $cfg
debug $"installing base with config ($cfg)"
mkdir /mnt/etc
install_base_packages
cp /etc/pacman.conf /mnt/etc/pacman.conf
run bash -c 'genfstab -U /mnt >> /mnt/etc/fstab'
}

@ -1,5 +1,26 @@
let RUN_IN_CHROOT = true;
let SUPPORTED_KERNELS = ["linux", "linux-zen", "linus-hardened", "linux-lts"];
# Applies all system changes of `install-kernels`
def main [cfg] {
echo "Executing up task `install-kernels` with config" $cfg
debug $"installing kernels with config ($cfg)"
mut kernel = $cfg.default
if $kernel not-in $SUPPORTED_KERNELS {
warn $"Unsupported kernel ($kernel). Defaulting to 'linux' kernel"
$kernel = "linux"
}
run pacstrap /mnt $kernel
debug "Installing additional kernels"
$cfg.additional | each {|$k|
debug $"installing ($k)"
if $k in $SUPPORTED_KERNELS {
run pacstrap /mnt $k
} else {
warn $"Unsupported kernel ($k)"
}
}
}

@ -1,8 +1,10 @@
mod debug;
mod info;
mod run;
mod warn;
mod with_cwd;
pub use debug::*;
pub use info::*;
pub use run::*;
pub use warn::*;
pub use with_cwd::*;

@ -59,14 +59,14 @@ impl embed_nu::nu_protocol::engine::Command for RunCommand {
let mut stdin = cmd.stdin.take().unwrap();
stdin.write_all(input.collect_string_strict(call.span())?.0.as_bytes())?;
if cmd.wait().is_err() {
if cmd.wait()?.success() {
Ok(PipelineData::empty())
} else {
Err(ShellError::ExternalCommand(
executable,
String::from("Is it written correctly?"),
call.span(),
))
} else {
Ok(PipelineData::empty())
}
}
}

@ -0,0 +1,36 @@
use embed_nu::{
nu_protocol::{engine::Command, Signature, SyntaxShape},
CallExt, PipelineData,
};
#[derive(Clone)]
pub struct WarnCommand;
impl Command for WarnCommand {
fn name(&self) -> &str {
"warn"
}
fn signature(&self) -> embed_nu::nu_protocol::Signature {
Signature::new("warn")
.rest("rest", SyntaxShape::Any, "the warning to print")
.category(embed_nu::nu_protocol::Category::Custom("Tourmaline".into()))
}
fn usage(&self) -> &str {
"Prints the given message and values with warning severity"
}
fn run(
&self,
engine_state: &embed_nu::nu_protocol::engine::EngineState,
stack: &mut embed_nu::nu_protocol::engine::Stack,
call: &embed_nu::nu_protocol::ast::Call,
_input: embed_nu::PipelineData,
) -> Result<embed_nu::PipelineData, embed_nu::nu_protocol::ShellError> {
let args: Vec<String> = call.rest(engine_state, stack, 0)?;
tracing::warn!("{}", args.join(" "));
Ok(PipelineData::empty())
}
}

@ -6,7 +6,7 @@ use std::fs;
use crate::{distro::OSConfig, error::ScriptError, utils::CFG_PATH};
use miette::{Context, IntoDiagnostic, Result};
use super::commands::{DebugCommand, InfoCommand, RunCommand, WithCwdCommand};
use super::commands::{DebugCommand, InfoCommand, RunCommand, WarnCommand, WithCwdCommand};
#[derive(Clone)]
pub struct ExecBuilder {
@ -25,6 +25,7 @@ impl ExecBuilder {
let mut ctx = embed_nu::Context::builder()
.with_command_groups(CommandGroupConfig::default().all_groups(true))?
.add_command(RunCommand)?
.add_command(WarnCommand)?
.add_command(InfoCommand)?
.add_command(DebugCommand)?
.add_command(WithCwdCommand)?

Loading…
Cancel
Save