Repository navigation
Support locked file flake inputs in fetchTree - #809
bobvanderlinden wants to merge 3 commits into
Conversation
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
zimbatm
left a comment
There was a problem hiding this comment.
Thanks for this. It fixes a user report: an input such as { url = "https://example.org/someone.keys"; flake = false; } stopped with "flake.lock missing or incomplete".
I built the branch and compared it with Nix 2.36.0:
- A real
httpsfile input gives the sameoutPath,narHashand content as Nix, in pure evaluation. e2e_flake,pureand the library tests pass.cargo clippy,cargo fmt --checkandast-grep scanare clean.
One defect, see the inline comment. After that, I think this can leave draft.
Not for this PR: an input written with type ({ type = "file"; url = "..."; }) still fails the lock comparison. That is a separate fix.
| None => { | ||
| !require_tree | ||
| && !url.path.last().is_some_and(|name| { | ||
| let name = name.to_ascii_lowercase(); |
There was a problem hiding this comment.
Nix compares the extension with hasSuffix, which is case-sensitive (hasTarballExtension in src/libfetchers/tarball.cc). So Nix locks file:///x.TAR.GZ with flake = false as type = "file". With to_ascii_lowercase, this branch reads it as tarball and reports the lock as stale. I checked this against Nix 2.36.0. Please compare the name as it is.
Locked non-flake inputs can be plain files. For example, Determinate's flake pins
determinate-nixdbinaries astype = "file"nodes with a URL andnarHash. Evaluating an output that uses one of those binaries currently fails infetchTree.Download the file without unpacking it and verify its single-file NAR against the lock. Nix may store a flat copy while downloading, but the
outPathexposed byfetchTreeis the recursivesourcepath. The lock'snarHashcan therefore name the path before download, so file inputs can use the existing substitution and input cache paths.nix flake prefetch-inputscan also handle these lock entries.The regression tests cover a cold fetch without Nix fallback, output path and contents parity with Nix, offline prefetch of a cached input, hash mismatch rejection, and the pure evaluation allow list for local URLs.