nix copy: allow excluding paths already in another cache
Is your feature request related to a problem?
What I assume is a fairly common use case for setting up caches is to only copy parts of the closure that are not already present in https://cache.nixos.org. Specifically, I want to copy a local store PATH to an s3:// target.
Some custom caching software including Cachix and Attic for example, have this set up by default. It allows caches to save storage space as I believe most users have cache.nixos.org configured.
Proposed solution
A new flag to exclude store paths already in a specified binary cache from copying. Similar to --substitute-on-destination, but the resolution is done on the source instead.
Alternative solutions
I thought of hacking together a solution, but the bug https://github.com/NixOS/nix/issues/12835 complicates things even further.
Additional context
This was previously proposed as https://github.com/NixOS/nix/issues/7527. No action was taken. The resolution to this issue is to use attic, which complicates a far simpler S3 + Cloudfront setup.
Checklist
- [x] checked latest Nix manual (source)
- [x] checked open feature issues and pull requests for possible duplicates
Add :+1: to issues you find important.