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

+44 -22
View File
@@ -2,31 +2,55 @@
// Authentication is whatever `oras login` has stored.
///|
fn oras(ctx : Ctx, args : String) -> String {
"oras " + args + (if ctx.cfg.plain_http { " --plain-http" } else { "" })
fn oras(ch : Channel, args : String) -> String {
"oras " + args + (if ch.plain_http { " --plain-http" } else { "" })
}
///|
fn repo_of(ctx : Ctx, name : String) -> String {
ctx.cfg.registry + "/" + name
fn repo_of(ch : Channel, name : String) -> String {
ch.url + "/" + name
}
///|
fn list_tags(ctx : Ctx, name : String) -> Array[String] raise OrbitError {
let out = capture(oras(ctx, "repo tags " + sq(repo_of(ctx, name)))) catch {
_ => raise OrbitError("package '\{name}' not found in \{ctx.cfg.registry}")
/// Whether oras output says the repository doesn't exist, as opposed to the
/// registry being unreachable or refusing access.
fn is_missing_repo(err : String) -> Bool {
contains_str(err, "name unknown") ||
contains_str(err, "response status code 404")
}
///|
/// The tags of `name` in a channel, or None if the channel doesn't have it.
/// Any other failure is an error: falling through to a lower priority channel
/// could install a different package with the same name.
fn list_tags(ch : Channel, name : String) -> Array[String]? raise OrbitError {
let errfile = trim(capture("mktemp"))
let cmd = oras(ch, "repo tags " + sq(repo_of(ch, name))) + " 2>" + sq(errfile)
let out = Some(capture(cmd)) catch { _ => None }
let err = match read_text(errfile) {
Some(t) => trim(t)
None => ""
}
sh("rm -f " + sq(errfile)) |> ignore
match out {
Some(o) => Some(lines(o))
None =>
if is_missing_repo(err) {
None
} else {
raise OrbitError("channel '\{ch.name}' (\{ch.url}): \{err}")
}
}
lines(out)
}
///|
fn resolve_digest(
ctx : Ctx,
ch : Channel,
name : String,
tag : String,
) -> String raise OrbitError {
let d = trim(
capture(oras(ctx, "resolve " + sq(repo_of(ctx, name) + ":" + tag))),
capture(oras(ch, "resolve " + sq(repo_of(ch, name) + ":" + tag))),
)
if !(has_prefix(d, "sha256:") || has_prefix(d, "sha512:")) {
raise OrbitError("unexpected digest for \{name}:\{tag}: '\{d}'")
@@ -37,12 +61,12 @@ fn resolve_digest(
///|
/// Fetch only the config blob (orbit.json); no layer download needed to plan.
fn fetch_manifest(
ctx : Ctx,
ch : Channel,
name : String,
digest : String,
) -> Manifest raise OrbitError {
let text = capture(
oras(ctx, "manifest fetch-config " + sq(repo_of(ctx, name) + "@" + digest)),
oras(ch, "manifest fetch-config " + sq(repo_of(ch, name) + "@" + digest)),
)
let m = parse_manifest(text)
if m.name != name {
@@ -59,6 +83,7 @@ fn fetch_manifest(
/// complete or absent.
fn fetch_into_store(
ctx : Ctx,
ch : Channel,
name : String,
digest : String,
) -> String raise OrbitError {
@@ -69,13 +94,10 @@ fn fetch_into_store(
let tmp = ctx.root + "/tmp/" + name + "-" + store_id(digest)
sh_ok("rm -rf " + sq(tmp) + " && mkdir -p " + sq(tmp + "/root"))
sh_ok(
oras(
ctx,
"pull -o " + sq(tmp) + " " + sq(repo_of(ctx, name) + "@" + digest),
) +
oras(ch, "pull -o " + sq(tmp) + " " + sq(repo_of(ch, name) + "@" + digest)) +
" >/dev/null",
)
if !(exists(tmp + "/pkg.tar.gz")) {
if !exists(tmp + "/pkg.tar.gz") {
raise OrbitError("\{name}@\{digest} has no pkg.tar.gz layer")
}
sh_ok(
@@ -101,7 +123,7 @@ fn fetch_into_store(
///|
/// Pack `<dir>/files` and push it with `<dir>/orbit.json` as the config blob.
fn publish(
ctx : Ctx,
ch : Channel,
dir : String,
also_latest : Bool,
) -> Unit raise OrbitError {
@@ -111,7 +133,7 @@ fn publish(
}
let m = parse_manifest(text)
let files = dir + "/files"
if !(exists(files)) {
if !exists(files) {
raise OrbitError("\{files} not found (package contents go in files/)")
}
for b in m.bins {
@@ -130,9 +152,9 @@ fn publish(
sh_ok("cp " + sq(dir + "/orbit.json") + " " + sq(tmp + "/orbit.json"))
let tags = if also_latest { m.version + ",latest" } else { m.version }
let push = oras(
ctx,
ch,
"push " +
sq(repo_of(ctx, m.name) + ":" + tags) +
sq(repo_of(ch, m.name) + ":" + tags) +
" --config " +
sq("orbit.json:" + CONFIG_MEDIA_TYPE) +
" --annotation " +
@@ -151,5 +173,5 @@ fn publish(
if rc != 0 {
raise OrbitError("oras push failed (exit \{rc})")
}
println("published \{m.name} \{m.version} to \{repo_of(ctx, m.name)}")
println("published \{m.name} \{m.version} to \{repo_of(ch, m.name)}")
}