Repository: nushell/nushell (Rust)

Issue:
NU_LIB_DIRS environment variable no longer working
### Describe the bug

Setting `let-env NU_LIB_DIRS` inside `env.nu` has no effect. Only `const NU_LIB_DIRS` works.

### How to reproduce

1. Inside `env.nu`: Set `let-env NU_LIB_DIRS = [  ($nu.config-path | path dirname | path join 'scripts') ]`
2. `const NU_LIB_DIRS` is not set anywhere
3. Put a file (`script.nu`) to the scripts folder
4. `source script.nu` inside `config.nu`
5. Error: File not found

### Expected behavior

Should work the same as before.

### Screenshots

_No response_

### Configuration

| key                | value                                                                                       |
| ------------------ | ------------------------------------------------------------------------------------------- |
| version            | 0.78.1                                                                                      |
| branch             | main                                                                                        |
| commit_hash        | 99c0a2575f22c754cc4e2ee14aa7e539dcc364b9                                                    |
| build_os           | linux-x86_64                                                                                |
| build_target       | x86_64-unknown-linux-gnu                                                                    |
| rust_version       | rustc 1.66.1 (90743e729 2023-01-10)                                                         |
| rust_channel       | 1.66.1-x86_64-unknown-linux-gnu                                                             |
| cargo_version      | cargo 1.66.1 (ad779e08b 2023-01-10)                                                         |
| build_time         | 2023-04-13 00:14:22 +03:00                                                                  |
| build_rust_channel | release                                                                                     |
| features           | default, zip                                                                                |
| installed_plugins  | from eml, from ics, from ini, from vcf, gstat, inc, query, query json, query web, query xml |


### Additional context


Discussion: Update: It's not related to the NU_LIB_DIRS PRs but at some point the way `$nu.config-path` is set changed. Now, it doesn't point at the default location anymore, but instead is set based on the `--config` flag and also resolves a symlink which is what caused my problem. Therefore, setting 
```
let-env NU_LIB_DIRS = [
    ($nu.config-path | path dirname | path join 'scripts')
]
```
([as set in default env.nu](https://github.com/nushell/nushell/blob/b9808c859836cdafb8d14d71079e0bcd90e7ac18/crates/nu-utils/src/sample_config/default_env.nu#L74-L76)) is not reliable anymore. We should probably have `$nu.default-config-dir` or something like that for this to keep working.
Maybe it was this PR https://github.com/nushell/nushell/pull/8792
Yeah, I think that PR is a good change, now we just need some way to refer to the default config location.
If no one is addressing this issue, I would like to.
But I am just a little confused and want to make sure my understanding.
I think the problem is that a user using a custom config directory (not default config dir `/home/<username>/.config/nushell/`) can't load scripts, which are placed in the default config dir, by using NU_LIB_DIRS now.
Is it correct?
Yeah, if you look at the default env.nu lines I linked above, you see the NU_LIB_DIRS is derived from `$nu.config-path` which can change depending on multiple factors. So, we need some way to refer to the default config directory so that the NU_LIB_DIRS would always be pointing at `/home/<username>/.config/nushell/scripts`.

The implementation should be quite easy: The `$nu` contents are defined during evaluation [here](https://github.com/nushell/nushell/blob/b2d7427d2def7aed26ba8b179f0d67b52406995f/crates/nu-engine/src/eval.rs#L1193) and the implementation of the NuVariable is [here](https://github.com/nushell/nushell/blob/main/crates/nu-engine/src/nu_variable.rs).



Fix (patch):
diff --git a/crates/nu-engine/src/nu_variable.rs b/crates/nu-engine/src/nu_variable.rs
index 65d2d4f6846be..0441bc4d51f91 100644
--- a/crates/nu-engine/src/nu_variable.rs
+++ b/crates/nu-engine/src/nu_variable.rs
@@ -25,7 +25,13 @@ pub struct NuVariable {
 
 impl LazyRecord for NuVariable {
     fn column_names(&self) -> Vec<&'static str> {
-        let mut cols = vec!["config-path", "env-path", "history-path", "loginshell-path"];
+        let mut cols = vec![
+            "default-config-dir",
+            "config-path",
+            "env-path",
+            "history-path",
+            "loginshell-path",
+        ];
 
         #[cfg(feature = "plugin")]
         if self.engine_state.plugin_signatures.is_some() {
@@ -70,6 +76,17 @@ impl LazyRecord for NuVariable {
         }
 
         match column {
+            "default-config-dir" => {
+                if let Some(mut path) = nu_path::config_dir() {
+                    path.push("nushell");
+                    Ok(Value::String {
+                        val: path.to_string_lossy().to_string(),
+                        span: self.span,
+                    })
+                } else {
+                    err("Could not get config directory")
+                }
+            }
             "config-path" => {
                 if let Some(path) = self.engine_state.get_config_path("config-path") {
                     let canon_config_path = canonicalize_path(&self.engine_state, path);
diff --git a/crates/nu-utils/src/sample_config/default_env.nu b/crates/nu-utils/src/sample_config/default_env.nu
index 4072b963be51e..fc6041ac68b21 100644
--- a/crates/nu-utils/src/sample_config/default_env.nu
+++ b/crates/nu-utils/src/sample_config/default_env.nu
@@ -72,14 +72,14 @@ let-env ENV_CONVERSIONS = {
 #
 # By default, <nushell-config-dir>/scripts is added
 let-env NU_LIB_DIRS = [
-    ($nu.config-path | path dirname | path join 'scripts')
+    ($nu.default-config-dir | path join 'scripts')
 ]
 
 # Directories to search for plugin binaries when calling register
 #
 # By default, <nushell-config-dir>/plugins is added
 let-env NU_PLUGIN_DIRS = [
-    ($nu.config-path | path dirname | path join 'plugins')
+    ($nu.default-config-dir | path join 'plugins')
 ]
 
 # To add entries to PATH (on Windows you might use Path), you can use the following pattern: