Manifest.nix "unexpected end of file" error while installing packages

I’ve been running NixOS for a few days now in a VM trying to configure it properly and get comfortable with the package manager.

Yesterday, I opened the VM and I got this error when I tried installing a package:

I know the package isn’t causing the error because I’ve tried installing other packages and all give me the same error.

After searching for a while I found this topic on this forum: File in nix store empty, unable to be repaired. I was trying the solution provided in the topic by running the command:

nix-store --query --referrers-closure $(find /nix/store -maxdepth 1 -type f -name '*.drv' -size 0)  | xargs nix-store --delete --ignore-liveness

But that gave me the following error:
image

And I’m unable to find a way to “ignore liveness”.

Please help. I would really like to make NixOS my primary OS.

Thanks a lot!

I don’t think I’d recommend just using that without thinking about why you need it.

Do you have ca-derivations enabled? Have you tried a simple nix-store --repair?

That said, it’s likely just that your user isn’t allowed to do that. You’ll need to sudo it.

2 Likes

I’m not exactly sure if I have ca-derivations enabled but I’m pretty sure I do because these are derivation files that are causing issues. How would I disable them if I had to?

And yes, I’ve ran nix-store --repair --verify multiple times to no avail.

env-manifest.nix is not a derivation file. Derivation files end in .drv.

env-manifest.nix is used by nix-env to keep track of what you have installed. Have you tried cat-ing it just to see what’s actually broken about it? It’s possible some nix-env operation would fix it, but I avoid that command like the plague so I wouldn’t know for sure.

Presumably the file ended up empty for some reason, and just installing and then uninstalling something with nix-env will fix it. Maybe you need to delete the broken version first (but I don’t think your command does that).

I don’t think you can undo making your store content addressed. It’s an experimental feature, and you would have had to use nix store make-content-addressed at some point in the past, or set the contentAddressed config option on nixpkgs (and then noticed your system rebuilding software a lot more).

You would also have had to set experimental-features = ca-derivations in your nix config at some point for it to even allow you to do any of the above.

My point is, unless you are doing so on purpose, you almost certaily aren’t using ca-derivations.

Sorry to bump but I haven’t found a good answer to this one. I am having this exact issue on NixOS 23.05 right now; I’ve noticed it affects both nix-env and home-manager (which I use so I can update a small set of desktop applications separately from the system packages); I can’t change what user-level packages/derivations I have installed with either of these because of that completely empty nix-env manifest. Uninstalling, installing, upgrading, or even querying user-level packages with nix-env all hit that same error. Someone on Reddit said they resolved this using nix-env --rollback but unfortunately I don’t currently have any older generations to rollback to.