I am trying to update and rebuild after several months (plus a new mobo and CPU), but am getting this error during rebuild: error: path '/nix/store/2cvzq9g5r5clwfzx3jng3kdh02zxqphy-linux-6.14-modules-shrunk/lib' is not in the Nix store. When I look in /nix/store/2cvzq9g5r5clwfzx3jng3kdh02zxqphy-linux-6.14-modules-shrunk/lib/modules the folder is 6.14.0-cachyos.
I was previously using the cachyos kernel from the Chaotic Nyx flake. I swapped to boot.kernelPackages = pkgs.linuxPackages_latest;, but am receiving the same error. Is it safe to just delete this path?
nixos-rebuild switch --impure --show-trace
warning: Git tree '/etc/nixos' is dirty
building the system configuration...
warning: Git tree '/etc/nixos' is dirty
error: path '/nix/store/2cvzq9g5r5clwfzx3jng3kdh02zxqphy-linux-6.14-modules-shrunk/lib' is not in the Nix store
Thanks for sharing your nix dotfiles. I was not able to reproduce your issue with them. You might have a corrupted nix store. Can you try running the following command with root permissions? nix-store --verify --check-contents --repair
If that won’t work, you might need to reinstall system. Don’t worry, installing NixOS does not wipe any data.
reading the Nix store...
checking path existence...
checking link hashes...
checking store hashes...
Building again after that resulted in the same error error: path '/nix/store/2cvzq9g5r5clwfzx3jng3kdh02zxqphy-linux-6.14-modules-shrunk/lib' is not in the Nix store
Is it time to just reinstall? Is there better way to do that from console or just boot from the ISO USB?
tldr there was a regression that broke building with nix 2.18.5, you can use a nix-shell like the following to build the configuration with a newer version of nix then swap to the resulting config:
Thanks, I made a shell.nix with your snippet and ran nix-shell which had Nix 2.28.3. Unfortunately, I get a similar error when running sudo nixos-rebuild build --impure in that shell:
error: path '/nix/store/4kmcb587yz035l7wsrqnnjiiyb5hmc77-linux-6.14.5-modules-shrunk/lib' is not in the Nix store
Did I miss a step in building my configuration from that shell?
I think you would have needed to put nixos-rebuild itself into the mkShell, as your present nixos-rebuild doesn’t use an updated nix from $PATH but its own hard-coded one. I had to do a stunt like this to use the new self.submodules thing.
Even more additional information for those who come after
I was unable to get this to work with just the shell above because my nix-daemon was still out of date.
I stopped my nix daemon (systemctl stop nix-daemon, systemctl stop nix-daemon-socket), sudo rmed the socket /nix/var/nix/daemon-socket/socket
I then started a nix daemon inside the shell from above (nix-daemon --daemon)
I then ran the rebuild in another shell, which then used that daemon and succeeded.
I hope this helps somebody in the future and saves them some time.
I’m also getting error: path '/nix/store/5ki9j1nrvdjw9fqvn7d6a2n8dgmv05al-linux-6.12.55-modules-shrunk/lib' is not in the Nix store just now, with nix (Nix) 2.18.2 and daemon of the same version.
But that dir is in my nix store (exists /nix/store), and contains things.
# nix-store --delete /nix/store/5ki9j1nrvdjw9fqvn7d6a2n8dgmv05al-linux-6.12.55-modules-shrunk/lib
finding garbage collector roots...
0 store paths deleted, 0.00 MiB freed
error: Cannot delete path '/nix/store/5ki9j1nrvdjw9fqvn7d6a2n8dgmv05al-linux-6.12.55-modules-shrunk' since it is still alive. To find out why, use: nix-store --query --roots
# nix-store -r /nix/store/5ki9j1nrvdjw9fqvn7d6a2n8dgmv05al-linux-6.12.55-modules-shrunk/lib
warning: you did not specify '--add-root'; the result might be removed by the garbage collector
/nix/store/5ki9j1nrvdjw9fqvn7d6a2n8dgmv05al-linux-6.12.55-modules-shrunk
How can it claim these things, and simultaneously claim it’s not in there?
Deleting and re-fetching:
# nix-store --delete $(nix-store -q --referrers-closure /nix/store/5ki9j1nrvdjw9fqvn7d6a2n8dgmv05al-linux-6.12.55-modules-shrunk/lib)
finding garbage collector roots...
deleting '/nix/store/lbrfvb2fnzcgfqql83qj08mn2lgs0bpp-boot.json'
deleting '/nix/store/dazb8wxyhl0gm6v7ni6zf1c1qza3csrk-initrd-linux-6.12.55'
deleting '/nix/store/a5m21c9l2gpz2v7jsxniqkz5xc99m8c2-boot.json'
deleting '/nix/store/cnlzkpm4n3ydvsjmwh74n9g1zi4zqhhh-initrd-linux-6.12.55'
deleting '/nix/store/5ki9j1nrvdjw9fqvn7d6a2n8dgmv05al-linux-6.12.55-modules-shrunk'
deleting unused links...
note: currently hard linking saves -0.00 MiB
5 store paths deleted, 26.47 MiB freed
# nix-store -r /nix/store/5ki9j1nrvdjw9fqvn7d6a2n8dgmv05al-linux-6.12.55-modules-shrunk/lib
this path will be fetched (2.35 MiB download, 2.53 MiB unpacked):
/nix/store/5ki9j1nrvdjw9fqvn7d6a2n8dgmv05al-linux-6.12.55-modules-shrunk
copying path '/nix/store/5ki9j1nrvdjw9fqvn7d6a2n8dgmv05al-linux-6.12.55-modules-shrunk'
a041086e600fe605f1098061f4ac8893f804ce94 is the first bad commit
commit a041086e600fe605f1098061f4ac8893f804ce94
Author: zowoq <59103226+zowoq@users.noreply.github.com>
Date: Thu Oct 23 22:10:40 2025 +0000
linux_6_12: 6.12.54 -> 6.12.55
pkgs/os-specific/linux/kernel/kernels-org.json | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
bisect found first bad commit
but I doubt that can really be the issue. However, reverting that allows me to at least build my NixOS VM tests to review PRs again…