- Add orbit.toml project manifests, deterministic orbit.lock files, [tasks], and `orbit run` - Add per-project .orbit/bin environments; `-g`/`--global` targets the global environment - Replace greedy global resolution with a lazy CDCL SAT solver that explains conflicts - Support channel::pkg dependency pins and comma-separated, comparison, and wildcard constraints - Cache immutable sha256 manifests under ~/.orbit/cache/manifests - Validate dependency keys and constraints in orbit.json
10 KiB
orbit
A small package manager written in MoonBit that uses any OCI registry (Gitea, GHCR, Harbor, registry:2, ...) as its repository, speaking the OCI Distribution v2 protocol directly over HTTP/TLS.
Status: builds cleanly (no warnings) with MoonBit
moonc v1.0.0-rc1/moon 0.1.20261126, and the unit tests pass. publish, install (with dependencies), upgrade, rollback, remove and gc have been exercised end to end against a localregistry:2and Gitea.
What it does
- Publish:
orbit publish <dir>packs<dir>/files/intopkg.tar.gzand pushes it with<dir>/orbit.jsonas the OCI config blob. - Lazy CDCL SAT solver: resolves global and project dependency graphs with backtracking, conflict explanations, and
channel::pkgdependency pins, reading only needed config blobs and caching immutablesha256manifests under~/.orbit/cache/manifests/. - Pixi-style project environments:
orbit new,orbit.tomlmanifests, deterministicorbit.locklockfiles,[tasks],orbit run, and isolated.orbit/bin/environments symlinked from the shared store (-g/--globaltargets the global environment inside a project). - Version constraints:
1.2.3,=1.2.3,==1.2.3,1.2,1.2.*,^1.2.0,~1.2.0,>=1.2,<=2.0,>1.0,<2.0,!=1.3.0,*, and comma-separated ranges (>=1.2.0, <2.0.0). Prereleases match only when the constraint mentions a-. - Content-addressed store: packages unpack into
~/.orbit/store/<name>/<digest>/, and their binaries are symlinked into~/.orbit/bin/(global) or<project>/.orbit/bin/(project). - File ownership: two packages can't provide the same binary.
- Upgrade and rollback: global installs keep the previous two builds, and
orbit rollback <name>switches back instantly with no network. - Remove:
orbit removerefuses to delete what other global packages need and autoremoves orphaned dependencies; in projects it updatesorbit.tomlandorbit.lock. - gc deletes store builds that are neither globally current nor kept for rollback.
Package format
mypkg/
orbit.json
files/
bin/mytool
share/...
{
"name": "mytool",
"version": "1.4.0",
"description": "Does a thing",
"documentation": "https://example.com/mytool",
"bin": ["bin/mytool"],
"depends": { "libfoo": "^2.1.0" }
}
In a channel this becomes <channel url>/mytool:1.4.0, plus the latest tag. The manifest sets artifactType to application/vnd.latha.orbit.v1, which is how orbit search tells Orbit packages apart from other OCI artifacts such as Helm charts. Packages published before this have no artifactType, so search also recognises the Orbit config media type:
| Part | Media type |
|---|---|
| config | application/vnd.latha.orbit.config.v1+json (orbit.json, with OCI labels for package-page metadata) |
layer pkg.tar.gz |
application/vnd.latha.orbit.layer.v1.tar+gzip |
The optional description and documentation fields supply Gitea's About
text and Documentation link. Use a public or otherwise accessible HTTP(S)
URL for the link. Gitea does not render a bundled README inline, but you can
ship one under files/share/doc/<name>/README.md, as the greet example does.
Because these are ordinary OCI artifacts, you can sign them with cosign or notation and attach SBOMs using the registry's own tooling.
Usage
Global environment
orbit login git.site.latha.org # once, with a Gitea token (needed to publish)
eval "$(orbit env)"
orbit publish examples/hello
orbit install hello
hello # -> hello from orbit
orbit upgrade
orbit rollback hello
orbit remove hello
Project workflow (Pixi-style)
Inside a directory with orbit.toml (or pass --manifest-path <path>), commands target the project unless you pass -g / --global:
orbit new myapp && cd myapp
orbit add hello example::greet
orbit run greet
orbit lock --update
orbit install --locked
orbit update
orbit remove hello
An orbit.toml looks like:
[project]
name = "myapp"
version = "0.1.0"
channels = ["example", "main"]
[[channels]]
name = "example"
url = "git.site.latha.org/nandi/example"
[dependencies]
hello = "^1.0.0"
greet = { version = ">=1.0.0, <2.0.0", channel = "example" }
[tasks]
hi = "greet"
Credentials are stored in ~/.orbit/auth.json ($ORBIT_ROOT/auth.json, mode 0600). Orbit also falls back to ~/.docker/config.json ($DOCKER_CONFIG/config.json) including credHelpers and credsStore. Use orbit logout <host> to remove stored credentials from Orbit.
Channels
Packages come from channels, which work like channels in pixi. A channel is a name for a registry namespace. The built-in main channel is git.site.latha.org/nandi, so no setup is needed.
Add your own in ~/.orbit/config.toml ($ORBIT_ROOT/config.toml), highest priority first. examples/config.toml adds the example channel:
[[channels]]
name = "example"
url = "git.site.latha.org/nandi/example" # host/namespace, no https://
# [[channels]]
# name = "local"
# url = "localhost:5000/pkgs"
# plain-http = true # registry without TLS
orbit channel add <name> <url> [--plain-http] appends one at the lowest priority, and orbit channel list shows the order. To remove or reorder channels, edit the file. orbit init creates a commented starter file.
orbit channel add example git.site.latha.org/nandi/example
orbit install greet # first channel that has greet
orbit install example::greet # from a specific channel
orbit publish examples/greet --channel example # default: main
mainis always included. It comes first, so another channel can't silently replace one of its packages. To lower its priority, add a block with onlyname = "main"where you want it.- Strict priority. The first channel that has a package name wins, even if a lower one has a newer or the only matching version. Dependencies are found the same way.
- Unreachable channels stop the lookup. Orbit moves to the next channel only when the registry says the package doesn't exist. Network and login errors fail.
- Packages remember their channel.
upgradeandrollbackkeep it.orbit install other::nameswitches it. A package stays tied to its channel name, so changing that channel's URL changes where upgrades come from. - Environment.
ORBIT_REGISTRY=<host>/<namespace>replaces the URL ofmain, andORBIT_PLAIN_HTTP=1applies tomain. Other channels aren't affected.
A config.json from an earlier version still sets the URL of main until a config.toml exists. orbit channel add carries it over.
For a local registry:2 without TLS:
docker run -d -p 5000:5000 registry:2
orbit channel add local localhost:5000/pkgs --plain-http
Building
moon build --target native --release
moon test --target native # semver / manifest unit tests
# the binary is _build/native/release/build/main/main.exe
Or run just install to build and copy the binary to ~/.local/bin/orbit.
It also adds Orbit's package bin directory to ~/.bashrc if the setup line
isn't already there. Open a new Bash shell or run source ~/.bashrc to pick
up the change in your current shell. ~/.local/bin must already be on PATH
to run orbit itself by name.
Linux only for now: arguments come from /proc/self/cmdline. It needs tar and /bin/sh on PATH.
Package Orbit with Orbit
From the repo root, build and stage the orbit package. The package version
comes from moon.mod; publishing is a separate step.
package_dir=$(sh scripts/package-orbit.sh) &&
_build/native/release/build/main/main.exe publish "$package_dir"
This publishes to the main channel (use --channel <name> for another), so log in with orbit login <host> first if needed. The
package contains a native Linux binary for the build machine's architecture.
Use the same architecture on the install machine. tar is still a
system prerequisite; the package does not bundle it.
To bootstrap from source, install the published package with the binary you just
built. After adding Orbit's bin directory to PATH, use the installed binary
for future upgrades and rollbacks:
bootstrap=_build/native/release/build/main/main.exe
"$bootstrap" install orbit
eval "$("$bootstrap" env)"
orbit upgrade orbit
# If needed: orbit rollback orbit
Layout
src/main/
stub.c C glue: time, termios echo toggle, getenv, symlink, stderr, exit
sys.mbt FFI bindings, UTF-8, string helpers, spinner, atomic writes
sha256.mbt streaming FIPS 180-4 SHA-256 (+ tests)
auth.mbt credentials store (~/.orbit/auth.json + Docker config fallback)
oci.mbt OCI Distribution v2 HTTP transport, Bearer/Basic auth, redirects
semver.mbt versions, relational/compound constraints, tag selection (+ tests)
model.mbt orbit.json / state.json / config.json (+ tests)
registry.mbt OCI registry ops: tags, resolve, cached manifests, fetch, publish, login
solver.mbt lazy Resolvo-style CDCL SAT solver & UNSAT explainer (+ tests)
ops.mbt SAT-backed global install/upgrade, remove/rollback/gc/search
project.mbt orbit.toml, orbit.lock, .orbit/ environments, project CLI (+ tests)
channels.mbt config.toml, channel priority and lookup (+ tests)
main.mbt CLI
registry_wbtest.mbt mock-OCI registry, SAT global, and project workflow tests
Toolchain notes
Fixes needed for current MoonBit, kept here in case you build with an older compiler:
- The project uses
moon.mod/moon.pkg(the.jsonforms are no longer accepted). suberror OrbitError { OrbitError(String) }, and@jsonis imported explicitly inmoon.pkg.Jsonvalues are built withJson::string,Json::array,Json::object,Json::boolean; the uppercase constructors are only used in patterns.- C FFI parameters are annotated
#borrow(...), matchingstub.c, which never decrefs its arguments.
Known limits
- There's no lock file for concurrent runs, and no install hooks, by design.
orbit gconly preserves global current and rollback builds (runorbit install/orbit syncin a project to re-populate missing store entries from itsorbit.lock).orbit info <name>reads globally installed package details without contacting the registry. Useorbit versions <name>to check published versions.searchneeds the registry's catalog API, which Gitea doesn't expose. Useorbit versions <name>if you already know the package name.