NixOS / nix

Nix, the purely functional package manager
https://nixos.org/
GNU Lesser General Public License v2.1
12.59k stars 1.51k forks source link

nix copies inputs already in the nix store #11228

Open yshui opened 2 months ago

yshui commented 2 months ago

Describe the bug

I have this in the nix registry.json

    {
      "exact": true,
      "from": {
        "id": "nixpkgs",
        "type": "indirect"
      },
      "to": {
        "path": "/nix/store/<some path>",
        "type": "path"
      }
    },

Running nix eval 'nixpkgs#hello.meta produces output "copying /nix/store/<some path>" every time.

I notice this doesn't not always happen. It happens if the "path" points to something that is built. In this case, my nixpkgs source is built by calling applyPatches. It does not happen if the "path" points to something that is fetched directly. e.g. if I use inputs.nixpkgs.url = github.com:nixos/nixpkgs, then points "path" to inputs.nixpkgs, then nix eval does not copy.

Expected behavior

nix should not copy if the input is already in the nix store.

Priorities

Add :+1: to issues you find important.

yshui commented 2 months ago

oh wait,

https://github.com/NixOS/nix/blob/ed0934b884b54ea174cb3d41a916f2e076d4c6d6/src/libfetchers/path.cc#L153

nix just special cases store paths whose names contain "source"??? :facepalm:

why? why not just do the same for all store paths?

yshui commented 2 months ago

yep, just need to name my derivation "source"...

this is kinda dumb