[Nix#9087] nix refetches the global registry json pointlessly for locally overriden flakes #110

Closed
opened 2024-03-16 06:44:57 +00:00 by lix-bot · 0 comments
Member

Upstream-Issue: NixOS/nix#9087

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.

Upstream-Issue: https://git.lix.systems/NixOS/nix/issues/9087 **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 :+1: to [issues you find important](https://github.com/NixOS/nix/issues?q=is%3Aissue+is%3Aopen+sort%3Areactions-%2B1-desc).
lix-bot added the
performance
imported
labels 2024-03-16 06:44:57 +00:00
jade added the
E/easy
E/help wanted
labels 2024-03-18 16:23:16 +00:00
jade added the
Area/flakes
label 2024-03-30 00:04:22 +00:00
midnightveil self-assigned this 2024-05-15 09:13:00 +00:00
jade closed this issue 2024-05-18 02:51:08 +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#110
No description provided.