Skip to main content
Version: 1.x

wasmcloud.toml

Even with all of wasmCloud's benefits, it still has every developers' least favorite file(s) - the config file. Luckily, we've cut it down to just one file and made it as simple as possible to use.

You can think of wasmcloud.toml as the package.json or Cargo.toml of the wasmCloud ecosystem. It's the main config file for any of your wasmCloud projects. Let's look at an example:

toml
name = "http-hello-world"
language = "rust"
type = "component"
version = "0.1.0"

[component]
wit_world = "hello"
wasm_target = "wasm32-wasi-preview2"

This is a fairly minimal configuration for a wasmCloud Rust hello world component. It defines everything needed to build and sign the component, including the language toolchain to use.

wash build

The partner-in-crime to wasmcloud.toml is wash build. This command takes all the options set in the wasmcloud.toml file to build and sign the component/provider/interface.

See the build docs for more info.

wasmcloud.toml Spec

Common Config

SettingTypeDefaultDescription
namestringName of the project
versionstringSemantic version of the project
pathstring{pwd}Path to the project directory to determine where built and signed artifacts are output
witstring./witPath to the directory where the WIT world and dependencies can be found
buildstring./buildPath to the directory where the built artifacts should be written
languageenum[rust, tinygo]Language that component or provider is written in
typeenum[component, provider, interface ]Type of wasmcloud artifact that is being generated
wasm_bin_namestring"name" settingExpected name of the wasm module binary that will be generated
overridesobjectOverrides for wit dependencies (often used for local dependencies)

Language Config - [tinygo]

SettingTypeDefaultDescription
tinygo_pathstringwhich tinygoThe path to the tinygo binary
disable_go_generatebooleanfalseWhether to disable the 'go generate' step in the build process

Language Config - [rust]

SettingTypeDefaultDescription
cargo_pathstringwhich cargoThe path to the cargo binary
target_pathstring./targetPath to cargo/rust's target directory

Registry Config - [registry]

SettingTypeDefaultDescription
urlstringN/AURL for the container registry to use when pushing images (i.e. wash push)
credentialsstringPath to a credentials file to use when pushing to container registries (ex. specified by url)

Type Config - [component]

SettingTypeDefaultDescription
claimslist[]The list of provider claims that this component requires. eg. ["wasmcloud:httpserver", "wasmcloud:blobstore"]
registrystringlocalhost:8080The registry to push to. eg. "localhost:8080"
push_insecurebooleanfalseWhether to push to the registry insecurely
key_directorystring~/.wash/keysThe directory to store the private signing keys in
wasm_targetstringwasm32-unknown-unknownCompile target. Can be one of: wasm32-unknown-unknown, wasm32-wasi-preview1, wasm32-wasi-preview2
call_aliasstringThe call alias of the component
build_artifactstring/path/to/project/build/{filename}.wasmOptional override path where wash can expect to find the built and unsigned WebAssembly artifact
build_commandstringLanguage specific commandOptional command to run instead of inferring the default language toolchain build command. Supports commands in the format of command ...arg. wash expects that the build command will result in an artifact under the project build folder named either {wasm_bin_name}.wasm if supplied or {name}.wasm otherwise.
destinationstring/path/to/project/build/{filename}_s.wasmFile path to output the destination WebAssembly artifact after building and signing.

Type Config - [provider]

SettingTypeDefaultDescription
capability_idstringThe capability ID of the provider
vendorstringThe vendor name of the provider

Type Config - [interface]

SettingTypeDefaultDescription
html_targetstring./htmlDirectory to output HTML
codegen_configstring.Path to codegen.toml file

WIT dependency fetch/pull configuration - [registry].pull

When fetching or pulling WIT interfaces (e.g. wasi:keyvalue, wasi:http), it can be useful to provide and/or override default sources. This effect can be achieved with the pull member of the [registry] configuration section in wasmcloud.toml.

Configuration for [registry].pull can be specified as a TOML table, as in the following example wasmcloud.toml:

toml
name = "example-component"
language = "rust"
type = "component"

[component]
wasm_target = "wasm32-wasip2"

[registry.pull]
sources = [
    { target = "wasmcloud:bus", source = "oci://ghcr.io/wasmcloud/targets" },
    { target = "test-components:testing", source = "file://extra-wit/pingpong.wit" },
    { target = "wasi:config", source = "https://github.com/WebAssembly/wasi-config/archive/v0.2.0-draft.tar.gz" },
    { target = "wasi:blobstore", source = "git+https://github.com/WebAssembly/wasi-blobstore.git" },
    { target = "wasi:messaging", source = "git+ssh://github.com/WebAssembly/wasi-messaging.git" },
]

Configuration for registry.pull can also be specified as a TOML array of tables, as in the following equivalent wasmcloud.toml:

toml
name = "example-component"
language = "rust"
type = "component"

[component]
wasm_target = "wasm32-wasip2"

[[registry.pull.sources]]
target = "wasmcloud:bus"
source = "oci://ghcr.io/wasmcloud/targets"

[[registry.pull.sources]]
target = "test-components:testing"
source = "file://extra-wit/pingpong.wit"

[[registry.pull.sources]]
target = "wasi:config"
source = "https://github.com/WebAssembly/wasi-config/archive/v0.2.0-draft.tar.gz"

[[registry.pull.sources]]
target = "wasi:blobstore"
source = "git+https://github.com/WebAssembly/wasi-blobstore.git"

[[registry.pull.sources]]
target = "wasi:messaging"
source = "git+ssh://github.com/WebAssembly/wasi-messaging.git"

The two above configurations have an identical effect.

The target used for an override can be at multiple levels:

  • Namespace (ex. wasi)
  • Package (ex. wasi:config)

For advanced use cases, overrides can also be specified with versions like so:

toml
[[registry.pull.sources]]
target = "wasi:messaging@0.2.1-draft"
source = "git+ssh://github.com/WebAssembly/wasi-messaging.git"

Overrides config (local files only) - [overrides]

deprecated

The [overrides] section differs from [registry].pull in that it only intended for local file based overrides. The [registry].pull supports overriding OCI registries, files, and other sources for WIT packages.

While projects that use [overrides] will continue to work, consider migrating to use [registry].pull.

Overrides are key-value pairs that can be used to override locations of wit dependencies. The key name should match the package reference without a version (e.g. wasi:http).

For example, if you have a dependency called my:local-dep@0.1.0 that is located in another directory, you can tell wash how to find it with the following overrides section:

toml
[overrides]
"my:local-dep" = { path = "../path/to/my/local/dep" }

It can also be used to override a version requirement for a package, but this is a highly advanced use case and should be used with caution.

toml
[overrides]
"my:local-dep" = { version = "^0.1.0" }