demo: Read the builder's store through the ssh wrapper
CI / Check (pull_request) Successful in 6m15s

Deploys and builds read built paths from the builder's store over
`ssh-ng`, with the `ssh` the broker's `nix` finds on its `PATH`. The
demo's wrapper wasn't named `ssh`, so `nix` used the real one, which
couldn't resolve `builder`. The wrapper is now `bin/ssh`, and also
handles how Nix calls it: the host as `builder@builder`, a control
master check and the `LocalCommand` it waits for.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
jackos1998andClaude Opus 5.5 committed 2026-11-29 01:28:01 +00:00
1 parent 58a11001b8
commit 974cc300cb
2 files changed
+31 -9

No files matched your search

+28 -9
View File
@@ -32,17 +32,36 @@ let
];
};
# The broker's `ssh`: the host `builder` runs the builder from this checkout's build directly, as
# its forced command would; everything else is the real `ssh`.
ssh = pkgs.writeShellScript "slop-demo-ssh" ''
host="" previous=""
# The broker's `ssh`, also `ssh` on the `PATH` of its `nix` (which takes it from the same
# directory): the host `builder` runs the builder from this checkout's build directly, as its
# forced command would, with the remote command in `SSH_ORIGINAL_COMMAND`. The broker passes the
# host after `--`; Nix passes `builder@builder` and the command after `--`, and waits for the
# `LocalCommand` it asks for. Everything else is the real `ssh`.
ssh = pkgs.writeShellScriptBin "ssh" ''
builder="" master=0 remote=() after=0 started=0
for arg; do
if [ "$previous" = -- ]; then host=$arg; break; fi
previous=$arg
if [ "$after" = 1 ]; then
remote+=("$arg")
elif [ "$arg" = -- ]; then
after=1
elif [ "$arg" = builder@builder ]; then
builder=nix
elif [ "$arg" = "-oLocalCommand=echo started" ]; then
started=1
elif [ "$arg" = -O ]; then
master=1
fi
done
if [ "''${#remote[@]}" -gt 0 ] && [ "''${remote[0]}" = builder ] && [ -z "$builder" ]; then
builder=broker
remote=("''${remote[@]:1}")
fi
if [ "$host" = builder ]; then
exec ${config.devenv.root}/target/debug/slop-broker builder --config ${builderConfig}
if [ -n "$builder" ]; then
# Nix checking for a control master, which the builder has none of
[ "$master" = 1 ] && exit 255
[ "$started" = 1 ] && echo started
SSH_ORIGINAL_COMMAND="''${remote[*]}" exec ${config.devenv.root}/target/debug/slop-broker builder --config ${builderConfig}
fi
exec ${pkgs.openssh}/bin/ssh "$@"
'';
@@ -99,7 +118,7 @@ let
audit_log = "${state}/audit.jsonl";
ssh = {
ssh = "${ssh}";
ssh = "${ssh}/bin/ssh";
key = "${state}/broker-key";
known_hosts = "${state}/known_hosts";
};
+3
View File
@@ -123,6 +123,9 @@ slop ssh web -- uptime </dev/null &
- **The builder** is reached over SSH, as in a real deployment.
- The broker's `ssh` is a wrapper that runs `slop-broker builder` from this checkout's build
when the host is `builder`, and the real `ssh` otherwise.
- It's named `ssh`, so the broker's `nix copy` and `nix path-info` use it too when they read
built paths from the builder's store (`ssh-ng://builder@builder`), which the builder serves
as `nix-daemon --stdio`.
- The builder fetches from the repository's path and evaluates with the host's Nix.
### Secrets