Settings that aren't part of a package, like which registries to use, how many jobs to run or whether to use the network, live in configuration files.
| File | Purpose | Commit it? |
|---|---|---|
| ~/.config/cx/config.toml ($XDG_CONFIG_HOME/cx/, APPDATA%\cx\ on Windows) | your personal defaults | no |
| <project>/.cx/config.toml | settings for one project, found by walking up from the current directory | yes |
| ~/.config/cx/credentials.toml | registry tokens only | never |
When a setting is given in several places, the most specific one wins:
| Key | Type | Environment variable | Default |
|---|---|---|---|
| registries.default | URL or path | CX_REGISTRY | none |
| registries.<name> | URL or path | CX_REGISTRY_<NAME> | none |
| net.offline | boolean | CX_OFFLINE | false |
| net.retries | 0 to 100 | 2 | |
| build.jobs | number | number of CPUs | |
| term.color | "auto", "always", "never" | NO_COLOR and friends (see Environment variables) | "auto" |
| build.compiler-cache | "auto", "sccache", "ccache", "none" or a program | CX_COMPILER_CACHE | "auto" (Build caches) |
| build.artifact-cache | boolean | CX_ARTIFACT_CACHE | false (Build caches) |
| build.artifact-store | URL or directory | CX_ARTIFACT_STORE | none (Build caches) |
| build.artifact-store-write | boolean | CX_ARTIFACT_STORE_WRITE | false |
| build.artifact-keys | list of "ed25519:<base64>" | none: entries need no signature | |
| build.artifact-signing-key | file | none: uploads aren't signed | |
| cache.auto-gc | an age like "90d", or "off" | CX_CACHE_AUTO_GC | off (Build caches) |
| source.vendor | directory | CX_VENDOR | none (Vendoring) |
| audit.database | git URL or directory | CX_AUDIT_DB | none (Security) |
| registries.<name>.keys | list of "ed25519:<base64>" | none (Security) | |
| registries.<name>.credential-provider | string or list (a provider) | none (Credential providers) | |
| registry.global-credential-providers | list of providers | ["cx:token"] (Credential providers) | |
| tools.cmake, tools.ninja, tools.clang-format, tools.clang-tidy, tools.doxygen, tools.python, tools.scons, tools.vcpkg, tools.make, tools.autoreconf | "auto", "system", "managed" or a program | CX_CMAKE, CX_NINJA, CX_CLANG_FORMAT, CX_CLANG_TIDY, CX_DOXYGEN, CX_PYTHON, CX_SCONS, CX_VCPKG, CX_MAKE, CX_AUTORECONF | "auto" (External tools) |
| tools.mirror | URL or directory | CX_TOOLS_MIRROR | none (External tools) |
A relative registry path (and a relative tools.* path) is relative to the directory that contains .cx/ (for the project file) or to ~/.config/cx/ (for the user file), not to the directory you run cx in.
Unknown keys get a warning, just as in cx.toml. A value of the wrong type is an error.
list shows each setting and where it came from, including environment variables. set and unset edit the file in place and keep its comments.
Private registries need a token. Store one with cx login, which reads it from standard input:
The token goes to ~/.config/cx/credentials.toml, which only you can read (mode 0600):
In CI, set CX_TOKEN (default registry) or CX_TOKEN_<NAME> instead. They win over the file.
How cx handles tokens:
Instead of credentials.toml, tokens can come from your operating system's credential store, a secret manager or a helper program. Configure a provider per registry, or a list of them for all registries:
| Provider | Where the token is |
|---|---|
| cx:token | credentials.toml (the default) |
| cx:keychain | the macOS keychain, the Windows Credential Manager, or the Secret Service on Linux (needs secret-tool from libsecret) |
| cx:token-from-stdout <COMMAND...> | printed by the command, e.g. a secret manager's CLI; read-only |
| <COMMAND...> | a helper program speaking the protocol below |
A provider is a string (split at spaces) or a list of arguments. A registry's credential-provider replaces the global list for that registry. The providers are asked in order, and the first token wins. CX_TOKEN and CX_TOKEN_<NAME> still win over all of them. cx login and cx logout store and remove the token with the first provider.
Providers only run when a request to the registry's host needs a token, at most once per run, so a locked build with a warm cache never runs one.
Helper protocol. cx runs the helper with one request on standard input, as key=value lines:
action is get, store (with a token=... line) or erase. For get, the helper prints token=<TOKEN>, or nothing if it has no token. A non-zero exit is an error. Its output is never shown, and its standard error goes to the terminal.