Nex.Env
(nex_core v0.4.3)
Copy Markdown
Environment variable management.
Loads from .env files and system environment.
Summary
Functions
Returns the current environment name as a string. Uses Mix.env() when available (dev/test), falls back to MIX_ENV env var, then defaults to "prod" - safe for compiled releases.
Detects project root directory. In dev/test (Mix available): walks up from _build app path. In prod release (no Mix): uses the directory of the running executable or cwd.
Get environment variable with optional default
Get required environment variable (raises if missing)
Get environment variable as boolean
Get environment variable as integer
Initialize environment from .env files.
Functions
Returns the current environment name as a string. Uses Mix.env() when available (dev/test), falls back to MIX_ENV env var, then defaults to "prod" - safe for compiled releases.
Can be overridden for testing with :mix_env and :system_env options.
Detects project root directory. In dev/test (Mix available): walks up from _build app path. In prod release (no Mix): uses the directory of the running executable or cwd.
Can be overridden for testing with :mix_project_path and :progname options.
Get environment variable with optional default
Get required environment variable (raises if missing)
Get environment variable as boolean
Get environment variable as integer
Initialize environment from .env files.
Options:
- :env - Override the environment name (default: auto-detected)
- :project_root - Override the project root path (default: auto-detected)