From 1c775fd53f3191469751d2c8bb4ba3a453ac8600 Mon Sep 17 00:00:00 2001 From: Brandon Norick Date: Wed, 18 Dec 2024 02:31:16 -0800 Subject: [PATCH 1/3] Makes two config related chages. - Adds MISE_GLOBAL_CONFIG_ROOT to control config_root for global config file - Allows MISE_IGNORED_CONFIG_PATHS to specify explicit paths --- src/config/config_file/mod.rs | 2 +- src/config/mod.rs | 2 +- src/env.rs | 4 ++++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/config/config_file/mod.rs b/src/config/config_file/mod.rs index 0110d34d0d..f8d41f2c86 100644 --- a/src/config/config_file/mod.rs +++ b/src/config/config_file/mod.rs @@ -242,7 +242,7 @@ pub fn parse(path: &Path) -> Result> { pub fn config_root(path: &Path) -> PathBuf { if is_global_config(path) { - return env::HOME.to_path_buf(); + return env::MISE_GLOBAL_CONFIG_ROOT.to_path_buf(); } let path = path .absolutize() diff --git a/src/config/mod.rs b/src/config/mod.rs index 6cfc362ba7..8ef566d8b9 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -909,7 +909,7 @@ pub fn load_config_paths(config_filenames: &[String], include_ignored: bool) -> config_files .into_iter() .unique_by(|p| file::desymlink_path(p)) - .filter(|p| include_ignored || !config_file::is_ignored(&config_trust_root(p))) + .filter(|p| include_ignored || !(config_file::is_ignored(&config_trust_root(p)) || config_file::is_ignored(&p))) .collect() } diff --git a/src/env.rs b/src/env.rs index e82807ee84..55d0fa1c86 100644 --- a/src/env.rs +++ b/src/env.rs @@ -114,6 +114,10 @@ pub static MISE_GLOBAL_CONFIG_FILE: Lazy = Lazy::new(|| { .or_else(|| var_path("MISE_CONFIG_FILE")) .unwrap_or_else(|| MISE_CONFIG_DIR.join("config.toml")) }); +pub static MISE_GLOBAL_CONFIG_ROOT: Lazy = Lazy::new(|| { + var_path("MISE_GLOBAL_CONFIG_ROOT") + .unwrap_or_else(|| HOME.to_path_buf()) +}); pub static MISE_SYSTEM_CONFIG_FILE: Lazy = Lazy::new(|| { var_path("MISE_SYSTEM_CONFIG_FILE").unwrap_or_else(|| MISE_SYSTEM_DIR.join("config.toml")) }); From 8a255844cf096df5b622c00b95ef850a72fd8c18 Mon Sep 17 00:00:00 2001 From: Brandon Norick Date: Wed, 18 Dec 2024 02:36:29 -0800 Subject: [PATCH 2/3] Updates docs --- docs/configuration.md | 6 ++++++ settings.toml | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/docs/configuration.md b/docs/configuration.md index 9ee1702db8..6a55b3cb21 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -342,6 +342,12 @@ Default: `$MISE_CONFIG_DIR/config.toml` (Usually ~/.config/mise/config.toml) This is the path to the config file. +### `MISE_GLOBAL_CONFIG_ROOT` + +Default: `$HOME` + +This is the path which is used as `{{config_root}}` for the global config file. + ### `MISE_ENV_FILE` Set to a filename to read from env from a dotenv file. e.g.: `MISE_ENV_FILE=.env`. diff --git a/settings.toml b/settings.toml index 3108d08f79..29e05a6150 100644 --- a/settings.toml +++ b/settings.toml @@ -330,6 +330,12 @@ type = "Path" optional = true description = "Path to the global mise config file. Default is `~/.config/mise/config.toml`. This must be an env var." +[global_config_root] +env = "MISE_GLOBAL_CONFIG_ROOT" +type = "Path" +optional = true +description = "Path which is used as `{{config_root}}` for the global config file. Default is `$HOME`. This must be an env var." + [go_default_packages_file] env = "MISE_GO_DEFAULT_PACKAGES_FILE" type = "Path" From a86ce46aec998e4efe5e96b14c22fbb97a9fbf2a Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Wed, 18 Dec 2024 10:42:41 +0000 Subject: [PATCH 3/3] [autofix.ci] apply automated fixes --- schema/mise.json | 4 ++++ src/config/mod.rs | 5 ++++- src/env.rs | 6 ++---- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/schema/mise.json b/schema/mise.json index 29d15dde02..c756a480ea 100644 --- a/schema/mise.json +++ b/schema/mise.json @@ -407,6 +407,10 @@ "description": "Path to the global mise config file. Default is `~/.config/mise/config.toml`. This must be an env var.", "type": "string" }, + "global_config_root": { + "description": "Path which is used as `{{config_root}}` for the global config file. Default is `$HOME`. This must be an env var.", + "type": "string" + }, "go_default_packages_file": { "default": "~/.default-go-packages", "description": "Path to a file containing default go packages to install when installing go", diff --git a/src/config/mod.rs b/src/config/mod.rs index 8ef566d8b9..8431a7ca9b 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -909,7 +909,10 @@ pub fn load_config_paths(config_filenames: &[String], include_ignored: bool) -> config_files .into_iter() .unique_by(|p| file::desymlink_path(p)) - .filter(|p| include_ignored || !(config_file::is_ignored(&config_trust_root(p)) || config_file::is_ignored(&p))) + .filter(|p| { + include_ignored + || !(config_file::is_ignored(&config_trust_root(p)) || config_file::is_ignored(p)) + }) .collect() } diff --git a/src/env.rs b/src/env.rs index 55d0fa1c86..88d4cd0d79 100644 --- a/src/env.rs +++ b/src/env.rs @@ -114,10 +114,8 @@ pub static MISE_GLOBAL_CONFIG_FILE: Lazy = Lazy::new(|| { .or_else(|| var_path("MISE_CONFIG_FILE")) .unwrap_or_else(|| MISE_CONFIG_DIR.join("config.toml")) }); -pub static MISE_GLOBAL_CONFIG_ROOT: Lazy = Lazy::new(|| { - var_path("MISE_GLOBAL_CONFIG_ROOT") - .unwrap_or_else(|| HOME.to_path_buf()) -}); +pub static MISE_GLOBAL_CONFIG_ROOT: Lazy = + Lazy::new(|| var_path("MISE_GLOBAL_CONFIG_ROOT").unwrap_or_else(|| HOME.to_path_buf())); pub static MISE_SYSTEM_CONFIG_FILE: Lazy = Lazy::new(|| { var_path("MISE_SYSTEM_CONFIG_FILE").unwrap_or_else(|| MISE_SYSTEM_DIR.join("config.toml")) });