Add install-desktops implementation

install-scripts
trivernis 2 years ago
parent 447ef2b48f
commit 427e8c8bf1
Signed by: Trivernis
GPG Key ID: DFFFCC2C7A02DB45

1217
Cargo.lock generated

File diff suppressed because it is too large Load Diff

@ -19,7 +19,7 @@ path = "src/main.rs"
clap = { version = "4.3.0", features = ["derive"] } clap = { version = "4.3.0", features = ["derive"] }
color-eyre = "0.6.2" color-eyre = "0.6.2"
dotenv = "0.15.0" dotenv = "0.15.0"
embed-nu = "0.7.0" embed-nu = "0.8.0"
lazy_static = "1.4.0" lazy_static = "1.4.0"
libc = "0.2.144" libc = "0.2.144"
miette = { version = "5.9.0", features = ["fancy"] } miette = { version = "5.9.0", features = ["fancy"] }

@ -1,4 +1,4 @@
def install [...packages: string] { def install [...packages] {
debug $"running pacman install for packages ($packages)" debug $"running pacman install for packages ($packages)"
eval $"run pacman -S --noconfirm ($packages | str collect ' ')" eval $"run pacman -S --noconfirm ($packages | str join ' ')"
} }

@ -11,7 +11,7 @@ module auto_partition {
info "Creating efi partitions" info "Creating efi partitions"
efi_layout $device efi_layout $device
if utils is_ssd $device { if ( utils is_ssd $device ) {
debug "Creating file systems for ssd" debug "Creating file systems for ssd"
efi_create_fs_ssd $device efi_create_fs_ssd $device
} else { } else {

@ -2,11 +2,225 @@ let RUN_IN_CHROOT = true;
def install_base [] { def install_base [] {
install networkmanager install networkmanager
install_pipewire
}
def install_pipewire [] {
( install
pipewire
pipewire-pulse
pipewire-alsa
pipewire-jack
wireplumber
helvum
)
}
module dm {
export def lightdm [] {
( install
lightdm
lightdm-greeter
lightdm-greeter-settings
)
run systemctl enable lightdm
}
export def gdm [] {
install gdm
run systemctl enable gdm
}
export def sddm [] {
install sddm
run systemctl enable sddm
}
}
module desktop {
use dm
export def onyx [] {
dm gdm
( install
xorg
onyx
sushi
)
}
export def gnome [] {
dm gdm
( install
xorg
gnome
sushi
)
}
export def kde [] {
dm sddm
( install
xorg
plasma
plasma-wayland-session
kde-utilities
kde-system
sddm
)
}
export def budgie [] {
dm lightdm
( install
xorg
budgie-desktop
gnome
xdg-desktop-portal
xdg-desktop-portal-gtk
xdg-utils
)
}
export def cinnamon [] {
dm lightdm
( install
xorg
cinnamon
metacity
gnome-shell
gnome-terminal
)
}
export def mate [] {
dm lightdm
( install
xorg
mate
mate-extra
)
}
export def xfce [] {
dm lightdm
( install
xorg
xfce4
xfce4-goodies
pavucontrol
)
}
export def enlightenment [] {
dm lightdm
( install
xorg
enlightenment
terminology
)
}
export def lxqt [] {
dm sddm
( install
xorg
lxqt
breeze-icons
nm-tray
xscreensaver
)
}
export def sway [] {
dm sddm
( install
xorg-xwayland
sway
bemenu
foot
mako
polkit
swaybg
xdg-user-dirs
dex
polkit-gnome
)
}
export def i3 [] {
dm lightdm
( install
xorg
i3-wm
dmenu
i3lock
i3status
rxvt-unicode
xdg-user-dirs
dex
polkit-gnome
)
}
export def herbstluftwm [] {
dm lightdm
( install
xorg
herbstluftwm
dmenu
dzen2
xorg-xsetroot
xdg-user-dirs
)
}
export def awesomewm [] {
dm lightdm
( install
xorg
awesome
dex
rlwrap
vicious
xdg-user-dirs
)
}
export def bspwm [] {
dm lightdm
( install
xorg
bspwm
sxhkd
xdo
xdg-user-dirs
)
}
} }
# Applies all system changes of `install-desktop` # Applies all system changes of `install-desktop`
def main [cfg] { def main [cfg] {
echo "Executing up task `install-desktop` with config" $cfg echo $"Installing desktop ($cfg)"
install_base install_base
todo "Implement install desktops"
use desktop
match $cfg {
"Onyx" => {desktop onyx},
"KdePlasma" => {desktop kde},
"Mate" => {desktop mate},
"Gnome" => {desktop gnome},
"Cinnamon" => {desktop cinnamon},
"Xfce" => {desktop xfce},
"Budgie" => {desktop budgie},
"Enlightenment" => {desktop enlightenment},
"Lxqt" => {desktop lxqt},
"Swaq" => {desktop sway},
"I3Gaps" => {desktop i3},
"HerbstluftWM" => {desktop herbstluftwm},
"AwesomeWM" => {desktop awesomewm},
"Bspwm" => {desktop bspwm},
}
} }

@ -14,9 +14,11 @@ use miette::Result;
#[tracing::instrument(level = "trace")] #[tracing::instrument(level = "trace")]
pub async fn create_executor(os_cfg_path: PathBuf) -> Result<TaskExecutor> { pub async fn create_executor(os_cfg_path: PathBuf) -> Result<TaskExecutor> {
let distro_config = DistroConfig::load().await?; let distro_config = DistroConfig::load().await?;
tracing::debug!("Distro config loaded");
let os_config = OSConfigLoader::new(os_cfg_path, &distro_config) let os_config = OSConfigLoader::new(os_cfg_path, &distro_config)
.load() .load()
.await?; .await?;
tracing::debug!("OS config loaded");
Ok(TaskExecutor::new(os_config, distro_config)) Ok(TaskExecutor::new(os_config, distro_config))
} }

@ -35,13 +35,19 @@ impl embed_nu::nu_protocol::engine::Command for EvalCommand {
let mut working_set = StateWorkingSet::new(engine_state); let mut working_set = StateWorkingSet::new(engine_state);
let (block, err) = nu_parser::parse(&mut working_set, None, &code.into_bytes(), false, &[]); let block = nu_parser::parse(&mut working_set, None, &code.into_bytes(), false);
if !working_set.parse_errors.is_empty() {
let err_messages = working_set
.parse_errors
.into_iter()
.map(|e| format!("{e:?}"))
.fold(String::new(), |acc, val| format!("{acc}{val}"));
if let Some(err) = err {
return Err(embed_nu::nu_protocol::ShellError::GenericError( return Err(embed_nu::nu_protocol::ShellError::GenericError(
String::from("ParseError"), String::from("ParseErrors"),
err.to_string(), err_messages,
Some(err.span()), None,
None, None,
vec![], vec![],
)); ));

@ -68,11 +68,11 @@ impl embed_nu::nu_protocol::engine::Command for RunCommand {
if cmd.wait()?.success() { if cmd.wait()?.success() {
Ok(PipelineData::empty()) Ok(PipelineData::empty())
} else { } else {
Err(ShellError::ExternalCommand( Err(ShellError::ExternalCommand {
executable, label: executable,
String::from("Is it written correctly?"), help: String::from("Is it written correctly?"),
call.span(), span: call.span(),
)) })
} }
} }
} }

@ -22,20 +22,25 @@ pub struct ExecBuilder {
} }
impl ExecBuilder { impl ExecBuilder {
#[tracing::instrument(level = "trace")]
pub fn create( pub fn create(
script: PathBuf, script: PathBuf,
os_config: OSConfig, os_config: OSConfig,
task_config: embed_nu::Value, task_config: embed_nu::Value,
distro_config: &DistroConfig, distro_config: &DistroConfig,
) -> Result<Self> { ) -> Result<Self> {
tracing::debug!("Loading script {script:?}...");
let script_contents = Self::get_script_contents(&script)?; let script_contents = Self::get_script_contents(&script)?;
let mut common_scripts = String::new(); let mut common_scripts = String::new();
for script in &distro_config.config.include_scripts { for script in &distro_config.config.include_scripts {
tracing::debug!("Loading include script {script:?}...");
common_scripts.push_str("\n"); common_scripts.push_str("\n");
common_scripts.push_str(&Self::get_script_contents(&script)?); common_scripts.push_str(&Self::get_script_contents(&script)?);
} }
tracing::debug!("Building context...");
let mut ctx = embed_nu::Context::builder() let mut ctx = embed_nu::Context::builder()
.with_command_groups(CommandGroupConfig::default().all_groups(true))? .with_command_groups(CommandGroupConfig::default().all_groups(true))?
.add_command(RunCommand)? .add_command(RunCommand)?
@ -56,6 +61,7 @@ impl ExecBuilder {
.add_script(common_scripts)? .add_script(common_scripts)?
.add_script(script_contents)? .add_script(script_contents)?
.build()?; .build()?;
if !ctx.has_fn("main") { if !ctx.has_fn("main") {
Err(ScriptError::MissingMain(script).into()) Err(ScriptError::MissingMain(script).into())
} else { } else {

Loading…
Cancel
Save