Skip to content

binary-cache: read narinfos with harmonia's parser#1793

Merged
Ericson2314 merged 2 commits into
NixOS:masterfrom
Mic92:narinfo-store-path
Jun 24, 2026
Merged

binary-cache: read narinfos with harmonia's parser#1793
Ericson2314 merged 2 commits into
NixOS:masterfrom
Mic92:narinfo-store-path

Conversation

@Mic92

@Mic92 Mic92 commented Jun 11, 2026

Copy link
Copy Markdown
Member

The StorePath field of a narinfo holds the full path
(/nix/store/<hash>-<name>); cache.nixos.org serves it that way and
harmonia_store_nar_info, used for our own uploads, writes it that way.
Our hand-rolled parse_narinfo fed the value into StorePath::from_str,
which only accepts the base name, so every spec-conforming narinfo failed
to parse.

The queue runner therefore could not read back narinfos from its own
binary cache: has_narinfo failed for every path, uploads were repeated
endlessly and copy_paths errors failed the affected builds. Observed on
a 120-build nixos-small evaluation against an S3 cache populated by the
runner itself: 2067 invalid value for StorePath errors and all 120
builds failing with status 2.

harmonia has since grown its own parse_narinfo_txt (mirroring nix's
nar-info.cc), so delegate to it instead of maintaining our own. It takes
the store directory explicitly, so carry it on S3CacheConfig, read from
the store query parameter of the cache URL (the nix S3 convention,
defaulting to /nix/store); both the upload and download paths now use
self.cfg.store_dir rather than threading it in. Besides reading
StorePath as a full path, this also fixes two ways our parser diverged
from nix: Deriver: unknown-deriver and an optional Compression field.

// only accepts the base name. Parsing via the store
// directory (assumed to be the default one throughout this
// function) also rejects narinfos for a different store.
store_path_opt = Some(StoreDir::default().parse(val).map_err(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fine for hydra.nixos.org, but the StoreDir here ought to be a parameter that we pass in.

(Also presumably this parsing logic is in Harmonia?)

@Ericson2314 Ericson2314 Jun 17, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nix-community/harmonia#1080 the logic is in Harmonia now (asked @amaanq to write from scratch)

@Mic92 Mic92 force-pushed the narinfo-store-path branch from d59671d to 19fc689 Compare June 11, 2026 17:18
The `StorePath` field of a narinfo holds the full path
(`/nix/store/<hash>-<name>`); cache.nixos.org serves it that way and
`harmonia_store_nar_info`, used for our own uploads, writes it that way.
Our hand-rolled `parse_narinfo` fed the value into `StorePath::from_str`,
which only accepts the base name, so every spec-conforming narinfo failed
to parse.

The queue runner therefore could not read back narinfos from its own
binary cache: `has_narinfo` failed for every path, uploads were repeated
endlessly and `copy_paths` errors failed the affected builds. Observed on
a 120-build nixos-small evaluation against an S3 cache populated by the
runner itself: 2067 `invalid value for StorePath` errors and all 120
builds failing with status 2.

harmonia has since grown its own `parse_narinfo_txt` (mirroring nix's
`nar-info.cc`), so delegate to it instead of maintaining our own. It takes
the store directory explicitly, so carry it on `S3CacheConfig`, read from
the `store` query parameter of the cache URL (the nix S3 convention,
defaulting to `/nix/store`); both the upload and download paths now use
`self.cfg.store_dir` rather than threading it in. Besides reading
`StorePath` as a full path, this also fixes two ways our parser diverged
from nix: `Deriver: unknown-deriver` and an optional `Compression` field.
@Ericson2314 Ericson2314 changed the title binary-cache: accept full store paths in narinfo StorePath field binary-cache: read narinfos with harmonia's parser Jun 24, 2026
@Ericson2314 Ericson2314 enabled auto-merge June 24, 2026 16:34
@Ericson2314 Ericson2314 added this pull request to the merge queue Jun 24, 2026
Merged via the queue into NixOS:master with commit 6f9fd52 Jun 24, 2026
2 checks passed
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.

2 participants