binary-cache: read narinfos with harmonia's parser#1793
Merged
Conversation
Ericson2314
reviewed
Jun 11, 2026
| // 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( |
Member
There was a problem hiding this comment.
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?)
Member
There was a problem hiding this comment.
nix-community/harmonia#1080 the logic is in Harmonia now (asked @amaanq to write from scratch)
d59671d to
19fc689
Compare
19fc689 to
1e9fbc0
Compare
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.
1e9fbc0 to
d5715af
Compare
Ericson2314
approved these changes
Jun 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
StorePathfield of a narinfo holds the full path(
/nix/store/<hash>-<name>); cache.nixos.org serves it that way andharmonia_store_nar_info, used for our own uploads, writes it that way.Our hand-rolled
parse_narinfofed the value intoStorePath::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_narinfofailed for every path, uploads were repeatedendlessly and
copy_pathserrors failed the affected builds. Observed ona 120-build nixos-small evaluation against an S3 cache populated by the
runner itself: 2067
invalid value for StorePatherrors and all 120builds failing with status 2.
harmonia has since grown its own
parse_narinfo_txt(mirroring nix'snar-info.cc), so delegate to it instead of maintaining our own. It takesthe store directory explicitly, so carry it on
S3CacheConfig, read fromthe
storequery parameter of the cache URL (the nix S3 convention,defaulting to
/nix/store); both the upload and download paths now useself.cfg.store_dirrather than threading it in. Besides readingStorePathas a full path, this also fixes two ways our parser divergedfrom nix:
Deriver: unknown-deriverand an optionalCompressionfield.