alqages/packages/amadaluzian-nu/0001-feat-config-add-NUSHELL_CONFIG_DIR-env-var.patch

43 lines
1.2 KiB
Diff
Raw Normal View History

From 8c96feb6397d4a5756dbeab1aedb7d2266c9218f Mon Sep 17 00:00:00 2001
From: Artur Manuel <balkenix@outlook.com>
Date: Tue, 11 Feb 2025 23:22:35 +0000
Subject: [PATCH] feat(config): add NUSHELL_CONFIG_DIR env var
---
crates/nu-path/src/helpers.rs | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/crates/nu-path/src/helpers.rs b/crates/nu-path/src/helpers.rs
index 931b3f9d0..cd3c07d95 100644
--- a/crates/nu-path/src/helpers.rs
+++ b/crates/nu-path/src/helpers.rs
@@ -1,4 +1,5 @@
use std::path::PathBuf;
+use std::env;
use crate::AbsolutePathBuf;
@@ -18,10 +19,15 @@ pub fn cache_dir() -> Option<AbsolutePathBuf> {
/// Return the nushell config directory.
pub fn nu_config_dir() -> Option<AbsolutePathBuf> {
- configurable_dir_path("XDG_CONFIG_HOME", dirs::config_dir).map(|mut p| {
- p.push("nushell");
- p
- })
+ let NUSHELL_CONFIG_DIR: Result<String, env::VarError> = env::var("NUSHELL_CONFIG_DIR");
+
+ match NUSHELL_CONFIG_DIR {
+ Ok(val) => Some(AbsolutePathBuf::try_from(val).unwrap()),
+ Err(_) => configurable_dir_path("XDG_CONFIG_HOME", dirs::config_dir).map(|mut p| {
+ p.push("nushell");
+ p
+ })
+ }
}
fn configurable_dir_path(
--
2.47.2