Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

locked nixpkgs index is redownloaded every hour #986

Closed
edrex opened this issue Feb 21, 2024 · 4 comments
Closed

locked nixpkgs index is redownloaded every hour #986

edrex opened this issue Feb 21, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@edrex
Copy link
Contributor

edrex commented Feb 21, 2024

Describe the bug
Expected behavior: the locked index should be cached as long as the GC root is pinned.
Observed: [155.8 MiB DL] downloading 'https://github.com/NixOS/nixpkgs/archive/ae5c332cbb5827f6b1f02572496b141021de335f.zip' after an hour.

I think this is an upstream issue, maybe the one discussed in https://discourse.nixos.org/t/pinned-nixpkgs-keeps-getting-garbage-collected/12912, but as honestly this is a huge usability papercut for devenv (I'd like to use it broadly, but these frequent refetches are too much) it seems wise to track here to move towards a solution. LMK if this is a dupe or something peculiar to my nix config. My devenv.yaml looks like:

inputs:
  nixpkgs:
    # use nixpkgs from system registry.
    url: nixpkgs
@edrex edrex added the bug Something isn't working label Feb 21, 2024
@domenkozar
Copy link
Member

Should be fixed in #745

@edrex
Copy link
Contributor Author

edrex commented Feb 24, 2024

Ok, I'll start testing the python impl and report back. Thanks Domen!

@domenkozar
Copy link
Member

Let me know if it does :)

@edrex
Copy link
Contributor Author

edrex commented Aug 25, 2024

Sorry for leaving this open for so long.

This issue is with nix itself, and isn't devenv-specific. Absent a link to a proper writeup, for anyone else struggling with frequent nixpkgs index refreshes, here's what to do:

  • Assuming you're using a flake to build the output that configures nix itself (either nixos, home-manager).
  • Use a direct path (skip the registry) for the nixpkgs input to that flake, like nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
  • Set nix.registry.nixpkgs.flake = inputs.nixpkgs; in your system config module (nixos, hm, darwin, nix-on-droid, etc). This says "use the locked version in the current flake at build time as the system registry nixpkgs". It results in a registry entry (nix registry list) that points at a store path, which ensures no network traffic.

There is a helper nix.generateRegistryFromInputs in the flake-utils-plus module that will do this for all your system flake inputs, which is handy but I haven't implemented it yet.

@edrex edrex closed this as completed Aug 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants