Skip to content

create cache entry for paths already in the nix store#12911

Merged
roberth merged 1 commit intoNixOS:masterfrom
Mic92:no-copy-twice
Apr 4, 2025
Merged

create cache entry for paths already in the nix store#12911
roberth merged 1 commit intoNixOS:masterfrom
Mic92:no-copy-twice

Conversation

@Mic92
Copy link
Copy Markdown
Member

@Mic92 Mic92 commented Apr 3, 2025

This allows path:/nix/store/* paths to not be copied twice to the nix store.

Motivation

Context


Add 👍 to pull requests you find important.

The Nix maintainer team uses a GitHub project board to schedule and track reviews.

@Mic92 Mic92 requested a review from edolstra as a code owner April 3, 2025 12:10
@github-actions github-actions bot added the fetching Networking with the outside (non-Nix) world, input locking label Apr 3, 2025
@Mic92 Mic92 force-pushed the no-copy-twice branch 3 times, most recently from 41f4413 to 5d3dd2d Compare April 3, 2025 13:11
@Mic92 Mic92 requested a review from Ericson2314 as a code owner April 3, 2025 13:11
@Mic92 Mic92 force-pushed the no-copy-twice branch 2 times, most recently from 64b673d to 220aba2 Compare April 4, 2025 08:58
Copy link
Copy Markdown
Member

@roberth roberth left a comment

Choose a reason for hiding this comment

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

This looks like an ok fix in terms of behavior, but I'm a little worried about the duplication between getAccessor and fetchToStore. Presumably the former could use the latter, or a factored out method?

@Mic92
Copy link
Copy Markdown
Member Author

Mic92 commented Apr 4, 2025

This looks like an ok fix in terms of behavior, but I'm a little worried about the duplication between getAccessor and fetchToStore. Presumably the former could use the latter, or a factored out method?

I am not quite sure how this is supposed to work. But I would also suggest that we would have a simple way to fix this issue because this is something I also want to backport.

This allows path:/nix/store/* paths to not be copied twice to the nix
store.
@roberth roberth merged commit 8bd342c into NixOS:master Apr 4, 2025
12 checks passed
@roberth roberth added backport 2.27-maintenance backport 2.28-maintenance Automatically creates a PR against the branch labels Apr 4, 2025
@Mic92 Mic92 deleted the no-copy-twice branch April 4, 2025 12:48
mergify bot added a commit that referenced this pull request Apr 4, 2025
…2911

create cache entry for paths already in the nix store (backport #12911)
Mic92 added a commit that referenced this pull request Apr 4, 2025
…2911

create cache entry for paths already in the nix store (backport #12911)
Mic92 added a commit that referenced this pull request Apr 4, 2025
…2911

create cache entry for paths already in the nix store (backport #12911)
Mic92 added a commit that referenced this pull request Apr 4, 2025
…2911

create cache entry for paths already in the nix store (backport #12911)
@roberth
Copy link
Copy Markdown
Member

roberth commented Apr 9, 2025

Part of releases:

  • 2.24.14
  • 2.28.0
  • 2.29.0 (TBD)

2.28 is a continuation of 2.27.
Other releases are unsupported.

@nixos-discourse
Copy link
Copy Markdown

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/2025-04-09-clan-weekly-changelog/62846/1

@nixos-discourse
Copy link
Copy Markdown

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/nix-copying-a-store-path-into-the-store/60409/16

getchoo added a commit to getchoo-contrib/nix that referenced this pull request Sep 22, 2025
Previously when creating the accessor for substituted/cached inputs, Nix
would neither:

- Ensure a cache entry exists for the substituted inputs (which are already in the store)
- Use the cache for substituted inputs. Instead, it attempted to find
  the always missing fingerprint of the original, unsubstituted input

Both of these led to severe slowdowns in some scenarios where a large
input (like Nixpkgs) had already been unpacked to the store but didn't
exist in a users cache, as described in NixOS#11228

The work in NixOS#12911 already fixed this
in most cases, but here we can ensure it applies to the substituted
store paths used for inputs
getchoo added a commit to getchoo-contrib/nix that referenced this pull request Sep 22, 2025
Previously when creating the accessor for substituted/cached inputs, Nix
would neither:

- Ensure a cache entry exists for the substituted inputs (which are already in the store)
- Use the cache for substituted inputs. Instead, it attempted to find
  the always missing fingerprint of the original, unsubstituted input

Both of these led to severe slowdowns in some scenarios where a large
input (like Nixpkgs) had already been unpacked to the store but didn't
exist in a users cache, as described in NixOS#11228

The work in NixOS#12911 already fixed this
in most cases, but here we can ensure it applies to the substituted
store paths used for inputs
getchoo added a commit to getchoo-contrib/nix that referenced this pull request Sep 24, 2025
Previously, Nix would not create a cache entry for substituted/cached
inputs

This led to severe slowdowns in some scenarios where a large input (like
Nixpkgs) had already been unpacked to the store but didn't exist in a
users cache, as described in NixOS#11228

Using the same method as NixOS#12911, we can
create a cache entry for the fingerprint of substituted/cached inputs
and avoid this problem entirely
getchoo added a commit to getchoo-contrib/nix that referenced this pull request Sep 25, 2025
Previously, Nix would not create a cache entry for substituted/cached
inputs

This led to severe slowdowns in some scenarios where a large input (like
Nixpkgs) had already been unpacked to the store but didn't exist in a
users cache, as described in NixOS#11228

Using the same method as NixOS#12911, we can
create a cache entry for the fingerprint of substituted/cached inputs
and avoid this problem entirely
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport 2.28-maintenance Automatically creates a PR against the branch fetching Networking with the outside (non-Nix) world, input locking

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants