I’m unable to build my nixos config on any computer after updating the flake to the latest revision. Each build gets stuck at the same place with the same error:
“error: path ‘/nix/store/9y7z0wj024np8zrhwvpz6ph6ksckiwgy-linux-6.12.20-modules-shrunk/lib’ is not in the Nix store”
To perform the update I ran nix flake update then nixos-rebuild as below. I’ve tested three systems built from the same flake and all fail at the same point.
Nix version: nix (Nix) 2.18.5, flake channel is set to nixos-unstable
The path exists, and has a folder structure that looks more or less correct.
So far I’ve tried:
changing kernel versions to the latest in case it was package specific
nix-store --gc and then rebuilding
manually removing and adding the path to nix-store
Not sure what else to do, or if I’m simply missing a step.
More complete output:
❯ nixos-rebuild switch --flake ./nixos#desktop --verbose --upgrade
$ nix --extra-experimental-features nix-command flakes build --out-link /tmp/nixos-rebuild.sREbZC/nixos-rebuild ./nixos#nixosConfigurations.“desktop”.config.system.build.nixos-rebuild --verbose
$ exec /nix/store/4j5la8m214m57xs81bfq9ixivky507fs-nixos-rebuild/bin/nixos-rebuild switch --flake ./nixos#desktop --verbose --upgrade
building the system configuration…
Building in flake mode.
$ nix --extra-experimental-features nix-command flakes build ./nixos#nixosConfigurations.“desktop”.config.system.build.toplevel --verbose --out-link /tmp/nixos-rebuild.b5Dze6/result
these 4 derivations will be built:
/nix/store/p4ng98h6yvsc543125976rccy4ycl274-closure-info.drv
/nix/store/fyv39zyaxny6p49pkj8bi81518x2ffz0-initrd-linux-6.12.20.drv
/nix/store/dsmh6vzhfgpi5p61d5fjhnazg1y4k2c9-boot.json.drv
/nix/store/0xnmgs1754yaiv85nrf5bln8p55a9l33-nixos-system-desktop-25.05.20250327.5e5402e.drv
error: path ‘/nix/store/9y7z0wj024np8zrhwvpz6ph6ksckiwgy-linux-6.12.20-modules-shrunk/lib’ is not in the Nix store
You should be able to reproduce the issue by trying to build the nix-lab nixosConfiguration, but weirdly garnix seemed to build it successfully last time I pushed changes (might have been built before a breaking change)
Thank you, switching to 24.11 does get the system to build. I’d still like to understand exactly what is causing the issue but at least I have a functional system.
I just switched back to nixpkgs-unstable and I’m no longer able to reproduce the issue, the build just works. Is it still an issue for you? Also can you post your flake/configs?
if you have either a different host with a newer nix version or docker/podman you could build it in the environment with a newer nix version then copy out the build configuration and switch to it with ./result/bin/switch-to-configuration switch?
So, I was able to reproduce this with Nix 2.18.5, but not the latest 2.18.x which is 2.18.9. So whatever the bug is, it was fixed by then.
@eureka-cpu Reported something similar, and in the revision of nixpkgs they said they were using before, Nix 2.18.5 was the default Nix version. So presumably that’s why they were affected. (Sidenote, that nixpkgs version is from july, so it must have been a while since you updated!)
So there must have been some bug with exportReferencesGraph that was fixed before 2.18.9. I’ve also tested it with Nix 2.3 (which is currently the oldest version of Nix that NixOS is required to remain compatible with) and it does not seem to exhibit the bug. So I don’t think that PR needs to be reverted. I think users simply need to be advised not to use obsolete versions of Nix, e.g. 2.18.5 when 2.18.9 exists.
This whole journey started when I realised I had misunderstood how nix updates work so yeah it had been a while.
Thank you for taking the time to replicate and help me understand the issue.
My understanding is that this is kind of a catch 22 scenario because in order to upgrade nix, I would need to be able to do a nixos-rebuild switch right? So in terms of avoiding this in the future, is there a way to run the latest version of nix regardless of whats in the store? For example with a ‘nix shell’ command or something?
I appreciate the follow up! Thanks very much. I was able to update to Warbler at least, I’m now at Nix 2.25.5, and I’m going to try to update to latest from here.
I’m not sure how well this would work but there is at least a latest version of nix the package in nixpkgs: nix - MyNixOS
Then you could make a shell.nix like so:
❯ nix build .#nixosConfigurations."nixos-work".config.system.build.toplevel
warning: Git tree '/home/felix/nixos' is dirty
error: path '/nix/store/pdi9qqvmgb8zwc0j7v1h0j7zpf43v424-linux-6.12.22-modules-shrunk/lib' is not in the Nix store
❯ nix --version
nix (Nix) 2.28.1
The problem lies in your nix daemon, I believe, not the nix version in your shell. You’ll need to update the daemon. For instance, you can update to the latest version of 24.11, which should be on a newer version of 2.18 which doesn’t have the issue. Then you should be able to update to anything from there.
Thanks! that was the missing piece! I hadn’t used this system in ~6 months, but had updated my config all the time because of other systems. So I checked when that commit you bisected (thanks so much! ) was merged, which was March 10, and switched to a git rev of my config before that. Then I was able to switch to that, nix-daemon --version showed an updated version, and then I was able to switch to current nixos-unstable again Thanks so much for writing all of this down, going the extra mile to bisect, and for helping me out!