Corrupted nix-env?

I tried that, but it failed in the same place. You said Exec format error could be due to a corrupted file, so I tried nix-store --delete /nix/store/xhz3ybvfn5s1qiza4fijd2l05cfd6082-nix-2.3.9/bin/nix --ignore-liveness , which resolved that particular error. There were other packages with similar errors (some ELF errors, which I assumed were the same problem). After doing that for several more packages that were giving me similar errors, nix-build -A system '<nixpkgs/nixos>' --repair was successful!

However, when attempting to run nixos-rebuild switch --upgrade one last time, the same error appears:

{18:18}~ ➭ nixos-rebuild switch --upgrade
unpacking channels...
error: syntax error, unexpected $end, at /nix/store/scd85qqipci9mf80vi42xg547x7wqr4z-env-manifest.nix:1:1
error: program '/nix/store/1hxgccnj93j33xap44v1dzzb24ly1m2r-nix-2.3.7/bin/nix-env' failed with exit code 1

And so I attempted to do the same with nix-store --delete /nix/store/scd85qqipci9mf80vi42xg547x7wqr4z-env-manifest.nix

… and it worked! :smiley: nixos-rebuild switch --upgrade now works perfectly fine.

Thank you so much @shlevy! And thank you @turboMaCk and @NobbZ!

I really appreciate everyone’s help here. NixOS and the NixOS community are absolutely amazing.

4 Likes

in theory nixos should be able to survive a incomplete upgrade…however, i guessing your system just went off… corrupted the filesystem the /nix/store was mounted on in someway.

I guess this was a hard crash, rather than a controlled shutdown…thus the filesystem was repaired, leading to truncated files?

What filesystem are you using? ext4?

Hi @nixinator Yes, I had typed nixos-rebuild switch and literally just hit ‘Enter’ no more than 2 seconds before my laptop shut itself off when the battery was too low (I’m on i3). I don’t know why it wasn’t a controlled shutdown, I need to look into that. Yes, ext4, on a LUKS device.

I bet if it wasn’t on a LUKS device, the filesystem may have recovered better… but a power off during an upgrade not great :-).

You got your system back working…cool.

Yeah this whole experience (first serious-ish problem I’ve had) has just made me love NixOS that much more. It really is unbelievably reliable.

1 Like

spread the word…tell your friends…

I rave about it all the time :slight_smile: my friends are probably sick of hearing about it by now lol

2 Likes