From 227e8dcc8dc1383745b8e883b13aaff384f07d8c Mon Sep 17 00:00:00 2001 From: Sourajyoti Basak Date: Fri, 5 May 2023 14:31:24 +0530 Subject: [PATCH] feat(shell): add `packer.nu` (#414) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat(shell): add `packer.nu` * dependency update (#413) * fix(main): move `packer.nu` step before linux package managers --------- Co-authored-by: Thomas Schönauer <37108907+DottoDev@users.noreply.github.com> --- src/main.rs | 5 +++++ src/steps/os/linux.rs | 21 ++++++++++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 1e893803..dde02169 100644 --- a/src/main.rs +++ b/src/main.rs @@ -177,6 +177,11 @@ For more information about this issue see https://askubuntu.com/questions/110969 } } + #[cfg(target_os = "linux")] + // NOTE: Due to breaking `nu` updates, `packer.nu` needs to be updated before `nu` get updated + // by other package managers. + runner.execute(Step::Shell, "packer.nu", || linux::run_packer_nu(&ctx))?; + #[cfg(target_os = "linux")] let distribution = linux::Distribution::detect(); diff --git a/src/steps/os/linux.rs b/src/steps/os/linux.rs index 64c0a764..9d6988f0 100644 --- a/src/steps/os/linux.rs +++ b/src/steps/os/linux.rs @@ -13,7 +13,7 @@ use crate::steps::os::archlinux; use crate::sudo::Sudo; use crate::terminal::{print_separator, print_warning}; use crate::utils::{require, require_option, which, PathExt}; -use crate::Step; +use crate::{Step, HOME_DIR}; static OS_RELEASE_PATH: &str = "/etc/os-release"; @@ -553,6 +553,25 @@ pub fn run_pacstall(ctx: &ExecutionContext) -> Result<()> { upgrade_cmd.arg("-Up").status_checked() } +pub fn run_packer_nu(ctx: &ExecutionContext) -> Result<()> { + let nu = require("nu")?; + let packer_home = HOME_DIR.join(".local/share/nushell/packer"); + + packer_home.clone().require()?; + + print_separator("packer.nu"); + + ctx.run_type() + .execute(nu) + .env("PWD", "/") + .env("NU_PACKER_HOME", packer_home) + .args([ + "-c", + "use ~/.local/share/nushell/packer/start/packer.nu/api_layer/packer.nu; packer update", + ]) + .status_checked() +} + fn upgrade_clearlinux(ctx: &ExecutionContext) -> Result<()> { if let Some(sudo) = &ctx.sudo() { ctx.run_type()