I am running NixOS on the unstable branch with flakes. I just updated my flake.lock and ran nixos-rebuild switch.
The build is taking a very long time seemingly because it is compiling linux-5.16.10 from source (though I’m quite surprised this is taking over an hour).
I don’t remember having this level of wait or a kernel compilationt the first time around. I have:
system = "x86_64-linux"
boot.kernelPackages = pkgs.linuxPackages_latest;
Could someone explain when NixOS will need to build the kernel from source, am I likely to have triggered this with some depedency?
More broadly, I’m aware that their are pre-built binaries in nixpkgs, but where are they stored, how can I tell if a package will have a prebuilt binary or be built from source?
update: it appears to be building every driver in the linux tree, 2 hours so far
Not everything in nixpkgs has be cached before nixos-unstable advances. Sometimes you might update in the window between when the channel advances and when the package you need is cached. I believe linuxPackages_latest is not required for the channel to advance. You can check if an update will require building locally with nixos-rebuild dry-build. Also, once you get a cache miss for a derivation, Nix will actually record that miss in ~/.cache/nix, so even once it is cached, you’ll still end up building locally. You can just delete this cache though without issue.
And yes, NixOS by default enables a lot of of kernel features, so it ends up being a fairly big build. Though 2 hours does seem an awful lot still… I can build it in a little over 10mins with my 16c/32t desktop, or a little over 20min on my 8 core Linux VM on an M1 Pro.
Usually I’d say the same, though on the other hand side, none of the nixos-* branches have been rebuilt in the last 2 days, except for the -small ones.
I’d expect the kernel to be available already, unless it gets pulled from master…
@NobbZ you were on the right lines, someone on matrix has pointed out to me that I was tracking master, not nixos-unstable (which is what I had intended):
TIL: master is merged to nixos-unstable passes CI, the CI process is responsible for caching NAR archives into S3 which are then served from cache.nixos.org. The 5.16.10 only landed in master a few days ago so I looks like it hadn’t made it to the cache yet.
Huh, I did not know that. That may explain some some builds I wasn’t expecting… Is there any way to disable that, or is it a side effect of nix’ caching model or such? I can’t imagine wanting this behavior for a distribution use case.