Skip to content

nix refetches the global registry json pointlessly for locally overriden flakes #9087

Open
@lf-

Description

Describe the bug

This is arguably in some respects the same bug as #7075 but only takes ${timeToCompleteHttpRequest}.

Given the following setup, nix will refetch the global registry when building things from non-fully-qualified flake reference:

~ » cat ~/.config/nix/registry.json
{
  "flakes": [
    {
      "from": {
        "id": "nixpkgs",
        "type": "indirect"
      },
      "to": {
        "lastModified": 1692557222,
        "narHash": "sha256-TCOtZaioLf/jTEgfa+nyg0Nwq5Uc610Z+OFV75yUgGw=",
        "owner": "nixos",
        "repo": "nixpkgs",
        "rev": "0b07d4957ee1bd7fd3bdfd12db5f361bd70175a6",
        "type": "github"
      }
    }
  ],
  "version": 2
}

~ » nix run --debug nixpkgs#hello
performing daemon worker op: 11
acquiring write lock on '/nix/var/nix/temproots/2597173'
performing daemon worker op: 1
using cache entry '{"name":"flake-registry.json","type":"file","url":"https://channels.nixos.org/flake-registry.json"}' -> '{"etag":"W/\"5af996fe37b5c4ba47ef9b3d545ba977b527e2dcdc6e926dda7787b7db6bcf6e\"","url":"https://channels.nixos.org/flake-registry.json"}', '/nix/store/5fjljy6g6l4lfdxcb1hjkg4bwrs2kqpx-flake-registry.json'
downloading 'https://channels.nixos.org/flake-registry.json'...
starting download of https://channels.nixos.org/flake-registry.json
finished download of 'https://channels.nixos.org/flake-registry.json'; curl status = 0, HTTP status = 304, body = 0 bytes

Steps To Reproduce

  1. Pin nixpkgs or another flake in the user or system registry.json
  2. nix run --debug nixpkgs#hello
  3. Observe that nix is performing a network request unnecessarily

Expected behavior

Nix should not refetch the registry if it can resolve the flake reference entirely locally.

nix-env --version output

~ » nix-env --version
nix-env (Nix) 2.17.0

Additional context

Priorities

Add 👍 to issues you find important.

Metadata

Assignees

No one assigned

    Labels

    fetchingNetworking with the outside (non-Nix) world, input lockingflakesperformance

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions