Skip to content

feat: implement migrate-nar-to-chunks command - #682

Merged
kalbasit merged 2 commits into
mainfrom
02-01-feat_implement_migrate-nar-to-chunks_command
Feb 1, 2026
Merged

kalbasit merged 2 commits into
mainfrom
02-01-feat_implement_migrate-nar-to-chunks_command

Conversation

@kalbasit

@kalbasit kalbasit commented Feb 1, 2026 •

Copy link
Copy Markdown
Owner

This adds a new command to migrate NAR files from traditional storage to content-defined chunks (CDC).

It iterates over NAR files in the storage, chunks them according to the CDC configuration, and stores the chunks in the backend. This implementation leverages the existing CDC package and ensures that the local cache is updated appropriately.

The command supports a dry-run mode and tracks progress throughout the migration process.

Part of #322

kalbasit commented Feb 1, 2026

Copy link
Copy Markdown
Owner Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @kalbasit, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a significant new feature: a migrate-nar-to-chunks command. This command enables users to transition their existing Nix Archive (NAR) files from conventional storage methods to a more efficient content-defined chunking (CDC) system. The migration process is robust, including options for dry-runs to prevent unintended data loss and detailed progress reporting to keep users informed. This enhancement aims to improve storage efficiency and management by leveraging CDC for NAR files.

Highlights

  • New migrate-nar-to-chunks Command: A new command-line utility has been added to migrate NAR files from traditional storage to content-defined chunks.
  • NAR to CDC Migration Logic: The command iterates through existing NAR files, chunks them using the CDC configuration, stores these chunks, and then removes the original NAR files from storage.
  • Dry-Run Support: The migration command includes a --dry-run flag, allowing users to simulate the migration process without making actual changes to the chunk store or deleting original NARs.
  • Progress Tracking: The command provides real-time progress updates during the migration, showing found, processed, succeeded, failed, and skipped counts, along with elapsed time and processing rate.
  • Public HasNarInChunks Function: The internal hasNarInChunks function in pkg/cache/cache.go has been made public as HasNarInChunks to support the migration logic.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩

@dosubot dosubot Bot added the size:XL This PR changes 500-999 lines, ignoring generated files. label Feb 1, 2026
@dosubot

dosubot Bot commented Feb 1, 2026

Copy link
Copy Markdown

Related Documentation

No published documentation to review for changes on this repository.

Write your first living document

How did I do? Any feedback?  Join Discord

@dosubot dosubot Bot added enhancement New feature or request go Pull requests that update go code labels Feb 1, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new migrate-nar-to-chunks command to migrate NAR files to content-defined chunks. The implementation is well-structured, leveraging an errgroup for concurrent processing and providing progress tracking. The changes also include exporting a function from the cache package for use in the new command and comprehensive tests for the new functionality.

I've identified a couple of areas for improvement in the new command's implementation, primarily related to the accuracy of the progress and summary reporting. The counter for processed items incorrectly includes items that were skipped, and the final summary log is missing the count of skipped items. My review includes suggestions to address these points.

Comment thread pkg/ncps/migrate_nar_to_chunks.go Resolved
Comment thread pkg/ncps/migrate_nar_to_chunks.go Resolved
@codecov

codecov Bot commented Feb 1, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.16%. Comparing base (0f88c9e) to head (42f9361).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #682   +/-   ##
=======================================
  Coverage   79.16%   79.16%           
=======================================
  Files           2        2           
  Lines         456      456           
=======================================
  Hits          361      361           
  Misses         83       83           
  Partials       12       12           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@kalbasit

kalbasit commented Feb 1, 2026

Copy link
Copy Markdown
Owner Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new migrate-nar-to-chunks command, which allows migrating existing NAR files from traditional storage to content-defined chunks. The implementation includes the CLI command, comprehensive documentation, and tests covering success, dry-run, and idempotency scenarios. The changes are well-structured and leverage existing components effectively. I've provided a couple of minor suggestions to improve logging consistency and code clarity. Overall, this is a great addition that enhances the storage efficiency capabilities of the service.

Comment thread pkg/ncps/migrate_nar_to_chunks.go Resolved
Comment thread pkg/ncps/migrate_nar_to_chunks.go Resolved
This adds a new command to migrate NAR files from traditional storage to content-defined chunks (CDC).

It iterates over NAR files in the storage, chunks them according to the CDC configuration, and stores the chunks in the backend. This implementation leverages the existing CDC package and ensures that the local cache is updated appropriately.

The command supports a dry-run mode and tracks progress throughout the migration process.
@kalbasit
kalbasit force-pushed the 02-01-feat_implement_migrate-nar-to-chunks_command branch from 99ba550 to 4d122ce Compare February 1, 2026 19:02
@kalbasit
kalbasit enabled auto-merge (squash) February 1, 2026 19:11
@kalbasit
kalbasit merged commit c35a1d3 into main Feb 1, 2026
@kalbasit
kalbasit deleted the 02-01-feat_implement_migrate-nar-to-chunks_command branch February 1, 2026 19:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request go Pull requests that update go code size:XL This PR changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant