Skip to content

Make fetchTarball lazy#468

Merged
edolstra merged 2 commits into
mainfrom
lazy-fetchTarball
May 22, 2026
Merged

Make fetchTarball lazy#468
edolstra merged 2 commits into
mainfrom
lazy-fetchTarball

Conversation

@edolstra

@edolstra edolstra commented May 21, 2026

Copy link
Copy Markdown
Collaborator

Motivation

This makes fetchTarball faster by (possibly) avoiding an unnecessary copy to the Nix store.

Context

Summary by CodeRabbit

  • Bug Fixes

    • Stronger SHA256 validation for downloaded files with clearer error behavior on mismatch.
  • Refactor

    • Streamlined tarball and single-file download flow with improved input caching and more reliable storage path handling.

Review Change Stack

@coderabbitai

coderabbitai Bot commented May 21, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 227a654e-ee21-4b70-b163-77ca305b5f63

📥 Commits

Reviewing files that changed from the base of the PR and between 2b59ffd and 7582c69.

📒 Files selected for processing (1)
  • src/libexpr/primops/fetchTree.cc

📝 Walkthrough

Walkthrough

fetch() now mounts tarball inputs via an input-cache pipeline when unpacking; otherwise it downloads files directly and, if provided, verifies Flat SHA256 before returning the store path.

Changes

fetch() URL download path refactoring

Layer / File(s) Summary
Tarball input-based fetch refactor
src/libexpr/primops/fetchTree.cc
When unpack is true, downloadTarball + fetchToStore are replaced by constructing a fetchers::Input of type "tarball" (url, name, optional narHash) and using state.mountInput to obtain and return the store path via state.mkStorePathString.
Single-file download with explicit hash verification
src/libexpr/primops/fetchTree.cc
When unpack is false, the file is downloaded via fetchers::downloadFile; if expectedHash is provided, the code recomputes the Flat SHA256 of the store object, throws EvalError (exit 102) on mismatch, and sets the store path with state.allowAndSetStorePathString.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~18 minutes

Poem

🐰 I hopped through code with eager eyes,
Tarballs mount where inputs rise,
Single files checked with hash so neat,
Old paths folded, new ones meet,
A carrot-coded change — concise and sweet!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Make fetchTarball lazy' directly relates to the main change: refactoring the fetch() function's tarball unpacking path to use fetchers::Input and input mounting instead of downloadTarball + fetchToStore, which aligns with making the operation lazy.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch lazy-fetchTarball

Comment @coderabbitai help to get the list of available commands and usage tips.

cole-h
cole-h previously approved these changes May 21, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/libexpr/primops/fetchTree.cc`:
- Around line 455-461: The Input for the tarball fetch drops the previously
parsed/validated name, breaking fetchTarball's contract and altering
expectedPath; update the attrs passed to fetchers::Input::fromAttrs so it
includes the parsed name when present (i.e. add the "name" attribute alongside
"type","url" and optional "narHash"), preserving the precomputed expectedPath
behavior used by fetchTarball and ensuring the attribute key matches callers
that read the name.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b49482ab-cc70-4220-9fa2-44fafff3cfb1

📥 Commits

Reviewing files that changed from the base of the PR and between 96df95f and 2b59ffd.

📒 Files selected for processing (1)
  • src/libexpr/primops/fetchTree.cc

Comment thread src/libexpr/primops/fetchTree.cc
@github-actions

github-actions Bot commented May 21, 2026

Copy link
Copy Markdown

@github-actions github-actions Bot temporarily deployed to pull request May 21, 2026 15:47 Inactive
@github-actions github-actions Bot temporarily deployed to pull request May 21, 2026 16:39 Inactive
@edolstra edolstra added this pull request to the merge queue May 21, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks May 21, 2026
@edolstra edolstra added this pull request to the merge queue May 22, 2026
Merged via the queue into main with commit 3b7d197 May 22, 2026
29 checks passed
@edolstra edolstra deleted the lazy-fetchTarball branch May 22, 2026 09:46
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