Path is not in the nix store during nixos-rebuild switch

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?

Post the output of nix --version, the exact command you ran, and ideally a link to your config or a minimal reproducible example.

nix --version          
nix (Nix) 2.18.5

Command I ran:

 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

Here is my repo of /etc/nixos files: GitHub - Jaage/nix-desktop

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.

1 Like

That command returned:

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?

Thanks for your help so far.

same issue as this Issue building linux kernel modules after Flake update

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:

{ pkgs ? import (fetchTarball "https://github.com/NixOS/nixpkgs/archive/nixos-unstable.tar.gz") { } }:
pkgs.mkShell {
  packages = with pkgs; [
    nixVersions.latest
  ];
}