Configuration and precedence model
Netherframe separates project inventory, execution settings, typed app inputs, and machine-local defaults into distinct layers so every run is explicit, auditable, and reproducible.
For a quick lookup of every key, flag, and default, see the Settings Reference and Configuration Reference.
Why there are no NF_* environment variables
Netherframe deliberately reads no NF_* environment variables for settings or app
inputs. An exported variable left behind in a shell or CI runner can silently retarget an
environment, alter recovery behavior, or change a state backend.
Instead, every value that shapes a run comes from an explicit source:
- Command-line flags (
nf apply --recovery-strategy rollback) - Project configuration (
[tool.nf]and[tool.nf.config]inpyproject.toml) - Python app code (
App(...)and backend arguments) - Typed app inputs (
++env=prodor++@prod.toml)
The only environment variables Netherframe honors are external tools' own variables (such
as CI, AWS_DEFAULT_REGION, VISUAL/EDITOR, NO_COLOR, and provider credentials like
AWS_PROFILE).
The four configuration surfaces
| Surface | Where it lives | What it controls |
|---|---|---|
| Project inventory | [tool.nf] in pyproject.toml |
Which apps exist (apps, terraform_apps), interpreter command (python), synthesis outdir |
| Execution settings | CLI flags, [tool.nf.config], App(...), ~/.config/nf/config.toml |
Concurrency, timeouts, backend target, recovery strategy, deferred approval, provider mirrors |
| Typed app inputs | Function parameters on the app factory (++name=value, ++@file) |
Environment name, replica counts, feature flags, Secret[T], Teardown[T] |
| TUI preferences | [tool.nf.tui] in pyproject.toml and [tui] in ~/.config/nf/config.toml |
Skin, keymap (k9s/emacs), graph line style, refresh interval, read-only apps |
[tool.nf] and [tool.nf.config] are separate tables with different jobs: [tool.nf]
tells the CLI how to find and load apps; [tool.nf.config] sets project-wide engine and
backend settings.
Settings precedence and conflict checking
Every execution setting resolves through nf.core.config.get_config_value() in a strict
five-level order:
- CLI flag (global option on
nf, written before or after the command, or command option; in Python,Project(settings=...)ornf.core.config.flags) - Project config (
[tool.nf.config]inpyproject.toml) - Code argument (
App(...)or backend constructor argument) - User config file (
$XDG_CONFIG_HOME/nf/config.toml, else~/.config/nf/config.toml, or--user-config FILE) - Built-in default
Two strict rules protect against configuration drift:
- Explicit conflict detection: If
[tool.nf.config]and an explicit code argument disagree on a setting, Netherframe raisesConfigurationErrorimmediately rather than silently picking one. Invalid setting values also fail fast. - Scoped user config:
~/.config/nf/config.tomlmay only hold machine-local preferences—TUI options ([tui]), logging (log-level,log-format,trace),non-interactive, and provider mirror/cache/credential paths. Engine and backend settings (recovery-strategy,backend-type,max-concurrent-resources) are rejected in user config so an infrastructure run never depends on who runs it. Passnf --no-user-configin CI to ignore the file completely.
Typed app inputs vs. settings
Use typed app inputs—not settings and not os.getenv—to vary what an app deploys
across environments:
from typing import Literal
from nf.core import App, Stack
def build_app(env: Literal["dev", "prod"] = "dev", region: str = "us-east-1") -> App:
app = App(
nf_id=f"platform-{env}",
context={"environment": env, "region": region},
deferred_validation=(env != "prod"),
)
Stack(
nf_scope=app,
nf_id="network",
metadata={"environment": env, "region": region},
)
app.enable_hybrid_execution_local(path=f".nf.out/platform-{env}.tfstate")
return app
Inputs are validated against their type annotations before any provider runs, recorded in
saved plans and state (nf destroy automatically reuses the last apply's deployment
inputs), and Secret[T] inputs are never accepted on the command line (pass them via
++@<(...) or Project(inputs=...)).
Backend selection precedence
When a hybrid app or legacy stack does not declare an explicit backend in Python code,
Netherframe resolves the backend from the backend_* settings (backend_type,
backend_s3_bucket, backend_s3_key_prefix, backend_s3_region, backend_s3_profile,
backend_local_path):
- An explicit backend declared in Python code wins.
- Otherwise, the
backend_*settings choose the backend (read fresh on every run—nothing is cached in.netherframe/backend.json). - Otherwise, hybrid apps default to local state at
.nf.out/nf.tfstate.
Run nf backend show to see the resolved backend, where each value came from, and the
exact state location.
Recommended project layout
[tool.nf]
python = ["uv", "run", "python"]
apps = ["infra.app:build_app"]
[tool.nf.config]
max_concurrent_resources = 20
recovery_strategy = "checkpoint"
backend_type = "s3"
backend_s3_bucket = "acme-infra-state"
backend_s3_key_prefix = "platform"
- Put app selectors and interpreter selection in
[tool.nf]. - Put project-wide operational defaults in
[tool.nf.config]. - Express environment selection and resource branching via typed app factory parameters.
- Override one-off run knobs with CLI flags (
nf plan --app build_app ++env=prod).