Skip to content

hydra-ad-hoc: fast-inline builds using remote protocol - #1908

Draft
tomberek wants to merge 3 commits into
NixOS:masterfrom
tomberek:fix/harmonia-fod-hash-encoding
Draft

tomberek wants to merge 3 commits into
NixOS:masterfrom
tomberek:fix/harmonia-fod-hash-encoding

Conversation

@tomberek

Copy link
Copy Markdown
Contributor

Also needed a harmonia bump.

WIP: is this the right direction to go in?

tomberek and others added 3 commits September 18, 2026 15:55
Nix's ssh-ng/ssh build-hook trusted-client fast path sends BuildDerivation
with the derivation content inline and never uploads a .drv file, so
hydra-ad-hoc's previous Builds-row-and-wait flow could never load it and
the client hung forever. Add an AdHocService.SubmitDerivation RPC that lets
hydra-queue-runner dispatch such a derivation straight to a machine,
bypassing Steps/Queues/Builds entirely, with a minimal UUID-keyed
completion path back to hydra-ad-hoc.

Also flip hydra-ad-hoc's trust_level() to NotTrusted: this makes Nix take
the .drv-uploading build_paths path for input-addressed derivations instead
of the inline fast path, so those get Hydra's normal dedup, previous-failure
caching, and wake-on-completion for free. Content-addressed derivations
still use the new inline path, since Nix takes that fast path for CA
derivations regardless of trust.

Known gaps: the new hydra-ad-hoc -> hydra-queue-runner gRPC client has no
TLS config, so it cannot connect when the queue runner has mTLS enabled;
and plain ssh:// (the legacy protocol) always behaves as trusted with no
way to signal otherwise, so it keeps using the inline path even for
input-addressed derivations.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
hydra-ad-hoc's build_derivation handler (the ssh-ng/ssh trusted-client
fast path) failed on any fixed-output derivation with "invalid nixbase32
hash at position N": harmonia's read_derivation_output/
write_derivation_output hardcoded Base::NixBase32 for a CAFixed output's
hash, but real Nix's derivation::write/parseDerivation (aterm.cc) encode
that hash as hex (Base16) -- the same ATerm writer is shared between .drv
files on disk and the BuildDerivation wire RPC, and both use hex there.

Already fixed upstream in nix-community/harmonia#1177 (merged
2026-08-27, e6a597b): the write side now uses Base::Hex, and the read
side auto-detects the encoding by length instead of assuming one fixed
base, matching how Nix's own hash parsing behaves. Bumping the pin picks
this up with no source changes needed on our side.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
- subprojects/hydra-ad-hoc/Cargo.toml: toml.workspace was alphabetically
  misplaced after tonic-prost instead of before tonic.
- subprojects/hydra-manual/src/architecture.md: regenerate to include
  the new hydra-ad-hoc -> hydra-proto edge added by the queue-runner
  client this branch introduces.

Verified with `nix flake check` (all checks green) after both fixes.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant