Why nixos switch from channel 24.11 to git clone nixpkgs cause large redownloads

I need to understand the mechanism on why this redownloaded everything.

I used the now quite old link
https://web.archive.org/web/20160327190212/http://anderspapitto.com/posts/2015-11-01-nixos-with-local-nixpkgs-checkout.html
as reference to switch from normal NixOS channels to a git clone of nixpkgs.

I modified it for recent changes (since the old nix-channels git is gone), so essentially all that is needed was:

cd /etc/nixos
git clone https://github.com/nixos/nixpkgs
cd nixpkgs
git checkout nixos-24.11

then in /etc/nixos/configuration.nix:

# here specify parent folder
nix.nixPath = [ "/etc/nixos" "nixos-config=/etc/nixos/configuration.nix" ];

then

nixos-rebuild switch

… now the entire thing is still running hours later because it’s redownloading about 33GB worth of sources since I have system.includeBuildDependencies = true; set, but it’s also redownloading base stuff.

So going by the commit hash on status.nixos.org:

nixos-24.11	a day ago	9684b53175fc

the commit from the local git clone was the same as the channel I was on (the default stable). Yet, it redownloads a ton of files as if all the derivation hashes had changed. Note that I’m using only binaries on this system (even though the sources are made to download).

Does anyone know why this switch would produce a massive redownload of store paths/sources? What is it about this switch that invalidates the prior downloads done via regular channel, when it points to the same commit?

I figure the article is quite old and maybe someone has run into it since.

I only skimmed that guide, though as it references the github:nixos/nixpkgs-channels repo, I want you to carefully read the README of that repo.

Then I want you to tell me, how your root users nix-channel --list looks like, as well as your regular users.

Nowhere in the post I have seen a hint for using a local clone, but only using the deprecated git-repo as a channel.

Thanks, yes indeed I did as it says:

DEPRECATED

Use NixOS/nixpkgs instead of NixOS/nixpkgs-channels going forward.
For more information see NixOS/nixpkgs#99257

A while ago we added the channel branches (nixos-* etc.) to the nixpkgs repository, so nixpkgs-channels is no longer necessary. However it still exists, which confuses people. I propose to archive it. Thus existing references will still work but we won't add new channels to it.

So I simply used the nixos-24.11 branch in the nixpkgs repo it appears to have moved to.

I did as the original article suggested (after the above) and further ran nix-channel remove nixos, so nix-channel --list under root user is simply empty. I doubted I had to remove it, but it at least tells you it must be going through git. Indeed, now, if I update git nixpkgs and re-run nixos-rebuild switch as root, everything works. My local users are not really used at all for this other than to pull git, but nix-channel --list for that user is now also empty (was going to tweak later, but I don’t need it yet).

For completeness’s sake (in case I post more stuff) I moved my source to this location for convenience which is the only thing I’ve changed in the past few days (using bind mounts - I think this looks official):

/nix/src/nixos/nixpkgs

so I now have:

nix.nixPath = [ "/nix/src/nixos" "nixos-config=/etc/nixos/configuration.nix" ];

So, regardless of any of this, I’ve been running the local repo without issue for the last few days, after it downloaded 30GB again. So, it seems to work fine this way, but I’m concerned about reproducibility because any workstation should be able to switch from channel to local git repo and vice-versa, since my own workstations would be mixed. Nobody is reporting this problem so I must be wrong.

It’s also that I thought I understood this part of the system, but some inherited attribute change somewhere must have rehashed everything; otherwise the generation appears somewhat context-dependent. So I figure there’s some attribute somewhere that I needed to port over - missing from the original article (from 2015?). How would I track that down?

I also went through some /nix/store/*.drv files like the system derivation from before/after the git change, and basically there was nothing different other than almost all the hashes. So I have no way to track down the attribute change that caused that, since it’s a giant mess.

In the worst case this is just part of the design, but I need to know why anyway.

Hi, I also have a local repository of nixpkgs using the release-24.11 branch, which is the current repository for 24.11, including all backported changes. I wonder why you use the nixos-24.11 branch.

The nixos-24.11 branch got already tested, and at least crucial tests suceeded, like it is ensured that booting works, and the kernel in some configurations, as well as systemd and more stuff.

While release-24.11 is where things get merged into and then get scheduled for testing.

This applies similarily for nixos-* vs release-* across all releases in the past and the future. And the same relationship exists between nixos-unstable and master.

Any nixpkgs-* branches are without the bootability tests and kernel tests, and therefore usually update quicker, though on the other hand side might be blocked by things failing building for MacOS.

You usually do not want to build a nixos-system from any non-nixos-prefixed branch or channel.

3 Likes

OK, clear, I set it to release-24.11 to test a patched package which was merged after package testing.