Skip to content

Config Manager

Xellu edited this page Jun 14, 2026 · 4 revisions

The config manager uses TOML configuration files for your project and services.

from nautica import Config, ConfigBuilder

Built-in Configs

Nautica creates two config files at the root of your project automatically:

File ID Description
config.n3 nautica Core Nautica settings
package-lock.n3 lock List of installed packages
project.n3 projectdev Config for package development

These are the only configs that live at the project root. All other configs are created under config/.

Reading Values

Use dotted key paths to read values from a config:

Config("nautica")["nautica.debug"] # True/False
Config("nautica")["http.port"] # 8100
Config("nautica")["http.static.directory"] # /path/to/directory

You can also call it directly:

Config("nautica")("http.port") # same as above

Both return None if the key doesn't exist

Writing Values

Config("nautica")["http.port"] = 9000

Changes are saved automatically.

ConfigBuilder

ConfigBuilder is used to define config keys with default values and optional comments:

ConfigBuilder()
    .add("key", default_value, comment="Optional comment")
    .build()

Keys use dot notation to define nested TOML tables:

ConfigBuilder()
    .add("database.host", "127.0.0.1", comment="Database host")
    .add("database.port", 5432)
    .add("database.name", "mydb")
    .build()

Turns into:

[database]
host = "127.0.0.1" # Database host
port = 5432
name = "mydb"

Creating a Config

Services can register their own config files using Config.New(). This should be done in onInstall():

from nautica import Service, Config, ConfigBuilder

class MyService(Service):
    def onInstall(self):
        Config.New("myservice",
            ConfigBuilder()
                .add("myservice.enabled", True, comment="Enable MyService")
                .add("myservice.host", "127.0.0.1")
                .add("myservice.port", 8200)
                .build()
        )

This creates config/myservice.toml with the defined keys and values. If the file already exists, missing keys are added without overwriting existing values.

Updating a Config

Use Config.Update() to add keys to an existing config without replacing it. This is useful for built-in configs like nautica that multiple services contribute to:

class MyService(Service):
    def onInstall(self):
        Config.Update("nautica",
            ConfigBuilder()
                .add("services.myservice", True, comment="Enable MyService")
                .build()
        )

Use Config.New() for your own config files, and Config.Update() when adding keys to an existing one like nautica.

Built-in Config Reference

nautica (config.n3)

Key Default Description
nautica.debug true Enables debug mode and debug log output
services.http false Enables the HTTP server
services.shell true Enables the shell
http.host 127.0.0.1 Server host
http.port 8100 Server port
http.realIPHeader "" Header to read real client IP from
http.logRequests true Log even non-error requests
http.websockets false Enable WebSocket support
http.includeSchema true Include request schema in error responses
http.docs false Expose OpenAPI Docs at /nautica:docs
http.static.enabled false Serve static files
http.static.endpoint /static Static files endpoint
http.static.directory /path/to/directory Static files directory
http.cors.enabled false Enable CORS
http.cors.origins ["*"] Allowed origins
http.cors.methods ["*"] Allowed methods
http.cors.headers ["*"] Allowed headers
http.cors.exposeHeaders [] List of exposed headers
http.cors.credentials false Allow credentials
shell.systemdMode false Disable console input for systemd
shell.gui false Use TUI renderer
shell.guiTheme frost TUI theme

projectdev (project.n3)

Key Default Description
name pwd Project name, a-z0-9._-
version 1.0.0 Semantic Version
dependsOn [] Dependency packages (names from registry)
pyPackages [] PyPI dependencies (names from PyPI)

Clone this wiki locally