Documentation

Walnut packages

Share Walnut source modules across apps: local path packages, GitHub/git pins, and a hostable package registry.

walnut install vendors resolved packages into vendor/walnut/ (commit that tree) so CI and offline builds do not need the network.

Packages compose TEA modules (import Foo). Native host libraries still live in the app’s ios/project.yml (with optional auto-merge from package host.spm).

The standard library stays toolchain-bundled — it is not a normal package.

Quick start

cd MyApp
walnut install
walnut check

Commit walnut.lock and vendor/walnut/.

App manifest (walnut.toml)

name = "MyApp"
bundle_id = "com.example.myapp"
sources = "src"
# runtime is set by `walnut new` / Homebrew; override only if needed

[packages]
vendor = true
path = "vendor/walnut"

[[source]]
name = "walnut"
url = "https://packages.walnutlang.com"

[dependencies]
Greeter = "0.1.0"                       # registry version
Shout = { path = "packages/Shout" }     # local path (copied into vendor on install)
Remote = { github = "org/repo", tag = "v0.1.0" }
FieldMeaning
[packages] vendorWhen true (default), materialize into path and expect it committed
[packages] pathVendor root (default vendor/walnut)
[[source]]Named registry base URL
string dep "0.1.0"Version from the default (first) source
pathLocal package directory (relative to the app)
git / githubRemote clone; lock stores commit; tree vendored without .git

Vendoring (offline / CI)

  1. Declare deps and [[source]].
  2. walnut install writes vendor/walnut/<Name>/ and walnut.lock.
  3. Commit vendor + lock. Teammates / CI run walnut install against the vendor tree without contacting the registry.
  4. walnut update may hit the network, then rewrites vendor.

Package layout (walnut-package.toml)

name = "Greeter"
version = "0.1.0"
modules = "src"

[dependencies]
  • modules — directory of .walnut files (default src)
  • organization — optional; publish as org/name
  • [[host.spm]] — merged into ios/project.yml on install

Each file declares module Prefixed.Name. Module names must be unique across the app and all packages. Prefer a package prefix (Greeter.Hello).

CLI

CommandRole
walnut install [dir]Resolve → vendor/walnut + walnut.lock
walnut add [email protected]Registry pin
walnut add path:packages/FooPath dep
walnut update [dir] [name]Refresh pin(s)
walnut login / publishRegistry auth + upload