cachix / devenv

Fast, Declarative, Reproducible, and Composable Developer Environments
https://devenv.sh
Apache License 2.0
4.54k stars 340 forks source link

locked nixpkgs index is redownloaded every hour #986

Closed edrex closed 3 months ago

edrex commented 9 months ago

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
domenkozar commented 9 months ago

Should be fixed in #745

edrex commented 9 months ago

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

domenkozar commented 9 months ago

Let me know if it does :)

edrex commented 3 months ago

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:

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.