Corruption in nix store

When I try to switch to my new configuration via a flake (sudo nixos-rebuild switch --flake .#host -L) I’m getting this error:

error: syntax error, unexpected invalid token, expecting '.' or '='

       at /nix/store/8ab0a9nkgm1d7cv22m923axawna0yj2z-source/maintainers/maintainer-list.nix:7895:6:

         7894|   };
         7895|   jwi�����I���
                             ���`u�ail = "johnw@newartisans.com";
             |      ^
         7896|     github = "jwiegley";
(use '--show-trace' to show detailed location information)
make[1]: *** [Makefile:7: switch] Error 1
make[1]: Leaving directory '/etc/nixos'
make: *** [Makefile:15: upgrade] Error 2

The file is really broken at that line.
But it looks ok at nixpkgs/maintainer-list.nix at 4e37b4e55b60fb7d43d2b62deb51032a489bcbe8 · NixOS/nixpkgs · GitHub.

Since /nix/store is read-only, how do I get out of this mess?

1 Like

Not sure if the new cli has an equivalent command yet, but there is nix-store --verify --check-contents --repair which will check hashes of all store paths and redownload any that are corrupted.

You might want to do a gc before hand as this can take quite a while, depending on your machine.

2 Likes

Thank you very much, I already tried --repair, which didn’t help. I’ll try all of them when I get to this machine later!

That path is simply a checkout of Nixpkgs; the one used by your flake. Which nixpkgs revision was locked in your flake?

I’d try to nix-store --delete /nix/store/8ab0a9nkgm1d7cv22m923axawna0yj2z-source and eval again. It should download Nixpkgs again and hopefully that time it won’t be corrupted.

It should have never corrupted in the first place though. This is likely an issue in a lower layer. Check your ram and/or disk. There might be an issue brewing up that might turn out to be critical.

3 Likes

Thank you, I’ll try that too. Yes, I’ll also need to do a MemTest86+. :see_no_evil: I get a lot of weird behavior on that machine.

nix-store --verify --check-contents --repair found and fixed a lot of errors, but not all. And it couldn’t fix my issue.
nix-store --delete /nix/store/8ab0a9nkgm1d7cv22m923axawna0yj2z-source removed the file, but then I just got error: cannot get archive member name: Damaged tar archive when I try to build my config again. :grimacing:

memtester found a lot of errors. :see_no_evil:

Yeah, I’d fix the RAM and then just re-install. Who knows what else might be corrupted. I’d also not trust user data anymore.

One RAM module is defective, I removed that now.
At least I can build my configuration again. :partying_face: I’m doing a nix-store --verify --check-contents --repair again. :grin:

So thanks a lot for the help you two!