Skip to content

Support locked file flake inputs in fetchTree - #809

Draft
bobvanderlinden wants to merge 3 commits into
numtide:mainfrom
bobvanderlinden:support-locked-file-inputs
Draft

bobvanderlinden wants to merge 3 commits into
numtide:mainfrom
bobvanderlinden:support-locked-file-inputs

Conversation

@bobvanderlinden

Copy link
Copy Markdown

Locked non-flake inputs can be plain files. For example, Determinate's flake pins determinate-nixd binaries as type = "file" nodes with a URL and narHash. Evaluating an output that uses one of those binaries currently fails in fetchTree.

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 outPath exposed by fetchTree is the recursive source path. The lock's narHash can therefore name the path before download, so file inputs can use the existing substitution and input cache paths. nix flake prefetch-inputs can 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.

@coderabbitai

coderabbitai Bot commented Dec 1, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

@zimbatm zimbatm left a comment

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.

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 https file input gives the same outPath, narHash and content as Nix, in pure evaluation.
  • e2e_flake, pure and the library tests pass. cargo clippy, cargo fmt --check and ast-grep scan are 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.

Comment thread src/flake/flakeref.rs
None => {
!require_tree
&& !url.path.last().is_some_and(|name| {
let name = name.to_ascii_lowercase();

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 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.

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