Skip to content

Pull nixpkgs as tarball from channels.nixos.org (another try)#62

Merged
edolstra merged 2 commits into
NixOS:masterfrom
xokdvium:channel-tarballs-hacks
Jun 27, 2026
Merged

Pull nixpkgs as tarball from channels.nixos.org (another try)#62
edolstra merged 2 commits into
NixOS:masterfrom
xokdvium:channel-tarballs-hacks

Conversation

@xokdvium

Copy link
Copy Markdown
Contributor

Actually working solution for #61. Don't even ask what "exact" is doing here, but it's load-bearing for this to work. Stuff like nix flake metadata nixpkgs/nixos-26.05 (and nix flake metadata nixpkgs) uses the channel tarballs, while nix flake metadata nixpkgs/master falls back to github:nixos/nixpkgs/master.

Actually working solution for NixOS#61.
Don't even ask what "exact" is doing here, but it's load-bearing for this to
work. Stuff like `nix flake metadata nixpkgs/nixos-26.05` uses the channel tarballs,
while `nix flake metadata nixpkgs/master` falls back to `github:nixos/nixpkgs/master`.
@xokdvium xokdvium changed the title Pull nixpkgs as tarball from channels.nixos.org Pull nixpkgs as tarball from channels.nixos.org (another try) Jun 26, 2026
@xokdvium

Copy link
Copy Markdown
Contributor Author

Ugh the CI is wrong here, to get the right behavior we explicitly should have the non-exact entry for nixpkgs last.

Registry resolution algorithm is order-dependent, and to get the desired
behavior with nixpkgs the indirect entry to `github:nixos/nixpkgs`
should come after all other exact entries.
@xokdvium

Copy link
Copy Markdown
Contributor Author

This particular feature has been around since NixOS/nix@7402451 (so forever).

Comment thread ci.sh
Comment on lines -8 to +9
nix registry list --tarball-ttl 0 --flake-registry "$PWD/flake-registry.json" \
| grep -- '^global ' | LC_ALL=C sort -u -c
nix registry list --tarball-ttl 0 --flake-registry "$PWD/flake-registry.json" |
grep -- '^global '

@xokdvium xokdvium Jun 26, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The sortedness requirement is kinda incorrect, the flake registry is order-dependent and "disorder" is required for the channel tarball redirects to function correctly (the exact matches should come first before the catch-all nixpkgs).

@edolstra edolstra merged commit 10bd3d9 into NixOS:master Jun 27, 2026
1 check passed
@xokdvium xokdvium deleted the channel-tarballs-hacks branch June 27, 2026 10:37
@pennae

pennae commented Jun 27, 2026

Copy link
Copy Markdown

we would strongly suggest making snapshots of the flake registry a build input to both lix and nix packages at the nixpkgs level. the registry changes very infrequently anyway, much less frequently than staging rebuilds happen. as it stands now the registry is materially worse than it was before because it's missing a bunch of nixpkgs versions, all of which lix (which ships a snapshot of the registry already for stability reasons) would have to track at all times. that's impractical for us to do and would make UX for our users significantly worse

@xokdvium

Copy link
Copy Markdown
Contributor Author

as it stands now the registry is materially worse than it was before because it's missing a bunch of nixpkgs versions

How so? Stuff like nixpkgs/nixos-25.05 falls back to github:nixos/nixpkgs/nixos-25.05.

@pennae

pennae commented Jun 27, 2026

Copy link
Copy Markdown

How so? Stuff like nixpkgs/nixos-25.05 falls back to github:nixos/nixpkgs/nixos-25.05.

ah, right. we misread part of the patch; we retract that criticism. we still suggest making a registry snapshot a build input of all flake-implementing nix implementations though for reliability, consistency, and not having to refetch the registry at runtime.

@xokdvium

Copy link
Copy Markdown
Contributor Author

we still suggest making a registry snapshot a build input

That does make sense to me, though the are of course pros and cons to that.

As a conservative start, the flake-registry could just be defined by default in the NixOS module at the nixpkgs level to make NixOS users not have to look it up at runtime. With update scripts the tedium of updating could be circumvented. I guess in practice vendoring it at build-time is also a workable option, but rebuilding nix (and dependent NixOS tests) in the bumps might be a bit annoying.

@pennae

pennae commented Jun 27, 2026

Copy link
Copy Markdown

shipping the registry via module settings is also on option, but lix will warn about that and potentially cause confusion. since registry changes are so rare we'd probably shove them into staging instead of going straight to the branches, that avoids most of the overhead and (seeing how lix hasn't yet had problems with a registry snapshot) probably won't negatively affect anything

@edolstra

Copy link
Copy Markdown
Member

FWIW Determinate Nix includes a built-in copy of the flake registry as a fallback for when fetching fails: DeterminateSystems/nix-src@535a168

That may be worth upstreaming.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants