Files
sausage/userland/bundle.nu
T
surma ec6e20a9d7 host: sausage run with the userland bundle, real shell and services (T13)
- userland/bundle.nu builds the userland and assembles target/userland/bin
  (bin names, tools.txt aliases, brush as sh and bash).
- run and sh take --userland (default SAUSAGE_USERLAND); /bin is read-only.
- The console's bash tool runs through the process table with the
  conversation id; large output spills to the world's /tmp.
- sausage run starts the services supervisor.

P1 exit session (openai/gpt-6.1-sol, fresh world): write, read, edit, git
init/add/commit/diff/log, grep -rn, rg, find and a sed|sort|uniq|wc pipeline.
2026-11-06 17:34:11 +00:00

37 lines
2.2 KiB
Nu

#!/usr/bin/env nu
# Build every workspace CLI and assemble the read-only /bin bundle.
def main [destination?: path] {
let here = $env.FILE_PWD
let destination = ($destination | default ($here | path join .. target userland bin) | path expand)
let object = ($here | path join cwd-init init.o)
let sources = [($here | path join cwd-init init.rs) ($here | path join cwd-init exit.wit) ($here | path join cwd-init build.nu)]
if not ($object | path exists) or ($sources | any {|source| (ls $source | get modified.0) > (ls $object | get modified.0) }) {
^nu ($here | path join cwd-init build.nu)
if $env.LAST_EXIT_CODE != 0 { error make {msg: 'cwd-init build failed'} }
}
let metadata = (do { cd $here; ^cargo metadata --no-deps --format-version 1 } | from json)
do { cd $here; ^cargo build --workspace --release --locked }
if $env.LAST_EXIT_CODE != 0 { error make {msg: 'userland build failed'} }
^nu ($here | path join brush build.nu)
if $env.LAST_EXIT_CODE != 0 { error make {msg: 'brush build failed'} }
mkdir $destination
for package in ($metadata.packages | where {|p| $p.id in $metadata.workspace_members }) {
let tools = ($package.manifest_path | path dirname | path join tools.txt)
for binary in ($package.targets | where {|t| 'bin' in $t.kind }) {
let source = ($metadata.target_directory | path join wasm32-wasip2 release $'($binary.name).wasm')
let names = if ($tools | path exists) { open --raw $tools | lines | where {|s| ($s | str trim) != '' } } else { [$binary.name] }
for name in $names {
^ln -f $source ($destination | path join $name)
if $env.LAST_EXIT_CODE != 0 { error make {msg: $'bundle link failed: ($name)'} }
}
}
}
let brush_metadata = (^cargo metadata --manifest-path ($here | path join brush source Cargo.toml) --no-deps --format-version 1 | from json)
let brush = ($brush_metadata.target_directory | path join wasm32-wasip2 release brush.wasm)
for name in [sh bash] {
^ln -f $brush ($destination | path join $name)
if $env.LAST_EXIT_CODE != 0 { error make {msg: 'brush link failed'} }
}
print $destination
}