Add pixi-style channels configured in config.toml

The built-in main channel is always included. Priority is strict, packages
remember their channel, and only a missing repository falls through to the
next channel.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
nandiandClaude Sonnet 5.5 committed 2026-11-26 18:40:55 -08:00
1 parent 32714325a7
commit 61ebc21fce
11 files changed
+639 -164

No files matched your search

+53 -24
View File
@@ -5,9 +5,13 @@ let usage : String =
#|orbit - packages as OCI artifacts (via oras)
#|
#|usage:
#| orbit init [registry] [--plain-http] set up; optionally save a registry
#| orbit publish <dir> [--no-latest] push <dir>/orbit.json + <dir>/files/
#| orbit install <name>[@constraint]... install with dependencies
#| orbit init create folders and config.toml
#| orbit channel list channels, highest priority first
#| orbit channel add <name> <url> [--plain-http]
#| orbit publish <dir> [--channel <name>] [--no-latest]
#| push <dir>/orbit.json + <dir>/files/
#| orbit install [channel::]<name>[@constraint]...
#| install with dependencies
#| orbit remove <name>... [--force] remove, then drop unused dependencies
#| orbit upgrade [name...] upgrade within constraints
#| orbit rollback <name> switch to the previous build
@@ -19,17 +23,14 @@ let usage : String =
#| orbit env print the PATH line for your shell
#|
#|constraints: 1.2.3 =1.2.3 1.2 ^1.2.0 ~1.2.0 >=1.2 *
#|environment: ORBIT_ROOT (default ~/.orbit), ORBIT_REGISTRY, ORBIT_PLAIN_HTTP=1
#|default registry: git.site.latha.org/nandi
#|config: <orbit root>/config.toml
#|environment: ORBIT_ROOT (default ~/.orbit); ORBIT_REGISTRY and
#| ORBIT_PLAIN_HTTP=1 override the built-in main channel
#|authentication: run `oras login <registry-host>` once.
///|
/// With no registry, only create the directories: any saved config is left
/// alone and the built-in default is not written to disk.
fn cmd_init(registry : String, plain_http : Bool) -> Unit raise OrbitError {
if registry == "" && plain_http {
raise OrbitError("usage: orbit init <registry> --plain-http")
}
/// Create the directories, and a config.toml if there is no config yet.
fn cmd_init() -> Unit raise OrbitError {
let root = orbit_root()
sh_ok(
"mkdir -p " +
@@ -39,14 +40,14 @@ fn cmd_init(registry : String, plain_http : Bool) -> Unit raise OrbitError {
" " +
sq(root + "/tmp"),
)
if registry != "" {
write_text_atomic(
root + "/config.json",
config_to_text(Config::{ registry, plain_http, }),
)
let config = root + "/config.toml"
// A legacy config.json is still honored, so don't hide it with a new file.
if !exists(config) && !exists(root + "/config.json") {
write_text_atomic(config, config_template)
}
println("orbit root: \{root}")
println("registry: \{load_ctx().cfg.registry}")
println("channels:")
print_channels(load_ctx().channels)
println("add to your shell profile:")
println(" export PATH=\"\{root}/bin:$PATH\"")
}
@@ -67,25 +68,53 @@ fn dispatch(args : Array[String]) -> Unit raise OrbitError {
let cmd = args[0]
let pos : Array[String] = []
let flags : Array[String] = []
for i = 1; i < args.length(); i = i + 1 {
if has_prefix(args[i], "--") {
let mut publish_to = MAIN_CHANNEL
let mut i = 1
while i < args.length() {
if args[i] == "--channel" {
if cmd != "publish" || i + 1 >= args.length() {
raise OrbitError("usage: orbit publish <dir> --channel <name>")
}
publish_to = args[i + 1]
i = i + 1
} else if has_prefix(args[i], "--") {
flags.push(args[i])
} else {
pos.push(args[i])
}
i = i + 1
}
match cmd {
"help" | "-h" | "--help" => println(usage)
"init" => {
cmd_init(
if pos.length() > 0 { pos[0] } else { "" },
flags.contains("--plain-http"),
)
if pos.length() > 0 {
raise OrbitError(
"init takes no arguments; use `orbit channel add <name> <url>`",
)
}
cmd_init()
}
"channel" => {
need(pos, 1, "channel list|add")
match pos[0] {
"list" => print_channels(load_ctx().channels)
"add" => {
need(pos, 3, "channel add <name> <url> [--plain-http]")
cmd_channel_add(
orbit_root(),
pos[1],
pos[2],
flags.contains("--plain-http"),
)
}
other => raise OrbitError("unknown channel command '\{other}'")
}
}
"env" => println("export PATH=\"\{orbit_root()}/bin:$PATH\"")
"publish" => {
need(pos, 1, "publish <dir>")
publish(load_ctx(), pos[0], !(flags.contains("--no-latest")))
let ch = find_channel(load_ctx(), publish_to)
publish(ch, pos[0], !flags.contains("--no-latest"))
}
"install" | "add" => cmd_install(load_ctx(), pos)
"remove" | "rm" => cmd_remove(load_ctx(), pos, flags.contains("--force"))