[Nix#7075] nix will pointlessly re-fetch flake inputs if they are defined as store paths not named "source" #630

Open
opened 2025-01-19 22:40:44 +00:00 by jade · 1 comment
Owner

Upstream-Issue: NixOS/nix#7075

Describe the bug

On my NixOS and nix-darwin machines I pin the system nixpkgs as nixpkgs so building stuff is faster, using nix.registry.nixpkgs.flake = nixpkgs; in my configuration.

/etc/nix/registry.json looks like so:

{"flakes":[{"exact":true,"from":{"id":"nixpkgs","type":"indirect"},"to":{"path":"/nix/store/cn1ag0zf4388i4s9ymx80hrqvma0p9qy-nixpkgs-src","rev":"36cc29d837e7232e3176e4651e8e117a6f231793","type":"path"}}],"version":2}
 » nix registry list
system flake:nixpkgs path:/nix/store/cn1ag0zf4388i4s9ymx80hrqvma0p9qy-nixpkgs-src?rev=36cc29d837e7232e3176e4651e8e117a6f231793
........

and every time I use nix-command with flakes it pointlessly copies from the nix store to the nix store:

$ nix shell nixpkgs#hello
copying '/nix/store/cn1ag0zf4388i4s9ymx80hrqvma0p9qy-nixpkgs-src'

Steps To Reproduce

  1. Put the result of:
» nix eval --expr '<nixpkgs>' --impure
/nix/store/cn1ag0zf4388i4s9ymx80hrqvma0p9qy-nixpkgs-src

into /etc/nix/registry.json replacing my path above.
2. nix run nixpkgs#hello

Expected behavior

Should execute instantly because it avoids gratuitously copying a store path to the store.

nix-env --version output

 » nix --version
nix (Nix) 2.10.3

however also reproduced on master:

co/nix - [master] » result/bin/nix --version
nix (Nix) 2.12.0pre20220921_f704c27
co/nix - [master] » result/bin/nix build nixpkgs#hello
copying '/nix/store/cn1ag0zf4388i4s9ymx80hrqvma0p9qy-nixpkgs-src

Additional context

Add any other context about the problem here.

Upstream-Issue: https://git.lix.systems/NixOS/nix/issues/7075 **Describe the bug** On my NixOS and nix-darwin machines I pin the system nixpkgs as `nixpkgs` so building stuff is faster, using `nix.registry.nixpkgs.flake = nixpkgs;` in my configuration. /etc/nix/registry.json looks like so: ```json {"flakes":[{"exact":true,"from":{"id":"nixpkgs","type":"indirect"},"to":{"path":"/nix/store/cn1ag0zf4388i4s9ymx80hrqvma0p9qy-nixpkgs-src","rev":"36cc29d837e7232e3176e4651e8e117a6f231793","type":"path"}}],"version":2} ``` ``` » nix registry list system flake:nixpkgs path:/nix/store/cn1ag0zf4388i4s9ymx80hrqvma0p9qy-nixpkgs-src?rev=36cc29d837e7232e3176e4651e8e117a6f231793 ........ ``` and every time I use nix-command with flakes it pointlessly copies from the nix store to the nix store: ``` $ nix shell nixpkgs#hello copying '/nix/store/cn1ag0zf4388i4s9ymx80hrqvma0p9qy-nixpkgs-src' ``` **Steps To Reproduce** 1. Put the result of: ``` » nix eval --expr '<nixpkgs>' --impure /nix/store/cn1ag0zf4388i4s9ymx80hrqvma0p9qy-nixpkgs-src ``` into /etc/nix/registry.json replacing my `path` above. 2. `nix run nixpkgs#hello` **Expected behavior** Should execute instantly because it avoids gratuitously copying a store path to the store. **`nix-env --version` output** ``` » nix --version nix (Nix) 2.10.3 ``` however also reproduced on master: ``` co/nix - [master] » result/bin/nix --version nix (Nix) 2.12.0pre20220921_f704c27 co/nix - [master] » result/bin/nix build nixpkgs#hello copying '/nix/store/cn1ag0zf4388i4s9ymx80hrqvma0p9qy-nixpkgs-src ``` **Additional context** Add any other context about the problem here.
Author
Owner

The bug here is that if a flake path is named "source" it is special cased. This is related to #529 which is a funny way to cause a crash.

I don't know the original justification for this special casing but it is probably not possible to remove without breaking back compat.

The bug here is that if a flake path is named "source" it is special cased. This is related to https://git.lix.systems/lix-project/lix/issues/529 which is a funny way to cause a crash. I don't know the original justification for this special casing but it is probably not possible to remove without breaking back compat.
jade changed title from [Nix#7075] nix will pointlessly re-fetch registry entries if they are defined as store paths to [Nix#7075] nix will pointlessly re-fetch flake inputs if they are defined as store paths not named "source" 2025-01-19 22:44:53 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: lix-project/lix#630
No description provided.