nushell / nushell

A new type of shell
https://www.nushell.sh/
MIT License
32.74k stars 1.7k forks source link

Consider supporting system-wide default-config-dir and data-dir #14378

Open michel-slm opened 1 week ago

michel-slm commented 1 week ago

Related problem

Right now both $nu.default-config-dir and $nu.data-dir point to local directories under the user's home directory

e.g. on Fedora

~> echo $nu.data-dir                  11/18/2024 03:01:22 PM
/home/michel/.local/share/nushell
~> echo $nu.default-config-dir        11/18/2024 03:01:29 PM
/home/michel/.config/nushell

See e.g. https://github.com/nushell/nushell/blob/main/crates/nu-utils/src/sample_config/default_env.nu#L80

Could this be extended to support reading from system-wide directories (e.g. /usr/share/nushell and /etc/nushell) and then have the user configurations overlaid on top? This is similar to how other shells put global config files in /etc/ and then have the user settings applied on top, potentially overriding the system config.

It will make it easier in Fedora to recommend other tools that already ship completions for other shells to ship completions for nushell as well in a consistent way.

Describe the solution you'd like

Have new directories defined as, e.g., $nu.system-data-dir and $nu.system-config-dir and have the default environment source those before sourcing the per-user config and data directories

Describe alternatives you've considered

We could just implement this downstream, but seems like it would cause more work both to maintain and if upstream nushell ends up implementing something different

Additional context and details

For Fedora, once upstream Nushell developers have decided on where the system directories should be (if they should exist at all), we can start the process on getting them added to the base filesystem package and the macros added to redhat-rpm-config so other packages can easily drop files into these

NotTheDr01ds commented 1 week ago

Side-note: if we do this, we'll also probably need to determine those equivalents for macOS and Windows.

Probably would be $env.PROGRAMDATA on Windows.