Skip to content

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] in pyproject.toml)
  • Python app code (App(...) and backend arguments)
  • Typed app inputs (++env=prod or ++@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:

  1. CLI flag (global option on nf, written before or after the command, or command option; in Python, Project(settings=...) or nf.core.config.flags)
  2. Project config ([tool.nf.config] in pyproject.toml)
  3. Code argument (App(...) or backend constructor argument)
  4. User config file ($XDG_CONFIG_HOME/nf/config.toml, else ~/.config/nf/config.toml, or --user-config FILE)
  5. 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 raises ConfigurationError immediately rather than silently picking one. Invalid setting values also fail fast.
  • Scoped user config: ~/.config/nf/config.toml may 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. Pass nf --no-user-config in 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):

  1. An explicit backend declared in Python code wins.
  2. Otherwise, the backend_* settings choose the backend (read fresh on every run—nothing is cached in .netherframe/backend.json).
  3. 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.


[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).