Skip to main content

Crate nu_config

Crate nu_config 

Source
Expand description

Nushell configuration infrastructure.

This crate owns all XDG-aware path resolution for Nushell configuration files and directories. It is the single source of truth for where config lives. It does not evaluate or parse config files — that is the job of nu-cli / the nu binary.

§Architecture

CLI flags + process env + platform dirs
             │
             ▼
     resolve_paths()          ← one-shot at startup
             │
             ▼
    NushellConfigDirs         ← stored on EngineState.config_dirs
             │
    ┌────────┼────────┬──────────────┐
    ▼        ▼        ▼              ▼
 $nu.*   loaders   history       plugins

After startup, do not re-read XDG_* env vars or call free path helpers. Always read from NushellConfigDirs.

§Resolution priority

For every path:

  1. CLI override (CliOverrides — e.g. --config-home, --config)
  2. XDG environment variable (e.g. $XDG_CONFIG_HOME)
  3. Platform default via the EnvAccess seam

§Testing

Use TestEnv to inject env vars and platform directories without touching the host process. Prefer unit tests in this crate over spawning nu for pure path-resolution logic.

Structs§

CliOverrides
CLI flags that affect where configuration files are found.
NushellConfigDirs
All resolved configuration directories and file paths for Nushell.
SystemEnv
Reads from the real process environment and dirs crate fallbacks.
TestEnv
In-memory environment + optional platform directory overrides for tests.

Enums§

ConfigError
Errors that can occur during config-path resolution.
ConfigFileKind
Metadata about the two kinds of Nushell configuration files.
ConfigPath
A resolved config-related file path that records whether it came from a CLI override or from the default location under config_home.
ConfigWarning
Non-fatal warnings produced during config-path resolution.

Traits§

EnvAccess
Abstraction over process environment and platform directory discovery so path-resolution logic can be unit-tested without touching the host.

Functions§

resolve_paths
One-shot entry point for resolving all Nushell configuration paths.