I’ve been trying out nixos for a few days, and I recently ran into trouble. Whenever I run any sort of nix-env command, I get an error like this: error: syntax error, unexpected end of file, at /nix/store/9xdi4s14daz4s89i2zx10g26ij3hkdr6-env-manifest.nix:1:1
I ran nix-store --verify-path /nix/store/9xdi4s14daz4s89i2zx10g26ij3hkdr6-env-manifest.nix and it indicates that the file was modified. However, nix-store --repair-path ... is unable to repair it.
I queried the store, and found that whatever package it is, it’s depended on by gtk3. If it was a different package, I might be able to get rid of it temporarily, run the garbage collector, and then re-install it. However, since gtk3 is a pretty important piece of software, I can’t exactly easily remove it.
Are the problematic store paths alive, or can you delete them with nix-store --delete and then recreate them and see if they’re still broken? (In theory you can delete live paths using the --ignore-liveness option. However, depending which paths you delete, that could have consequences)
So I reinstalled NixOS, hoping that a clean install would fix it, but it didn’t, not too sure as to why though. I find it hard to believe that a completely new install would carry the same issues (but I guess Nix is reproducible, even the problems).
At first I reinstalled, using my normal config, which didn’t work. Then, I reinstalled with a semi-minimal config (just KDE and some basic packages) and had the same problems.
I literally have no idea what would be causing this, it feels like I’ve tried most simple solutions, and haven’t found one that works.
Normally I wouldn’t mind this too much, I can still build my config, but home manager can’t run so I can’t config user-level applications. Does anyone know what’s going on here?
The exact same thing happened to me a week ago. I did have ca-derivations and keep-derivations enabled in nix.conf, and auto-optimise-store = false by the way.
Unfortunately, nix-store --repair did not work!!
Log of what happened to me
Here’s a more complete log of what happened. I can’t remember the nixpkgs rev off the top of my head though.
root@tethys:~ # nixos-rebuild switch
this derivation will be built:
/nix/store/78mw9fbgdmn7jbpqkam53smy3jxhkpzz-nixos-rebuild.drv
building '/nix/store/78mw9fbgdmn7jbpqkam53smy3jxhkpzz-nixos-rebuild.drv'...
/nix/store/a9skvgykplgx882i0wgf3k4gqj7nm9i2-stdenv-linux/setup: line 754: /nix/store/wj4z7145vcph0mp3h78afvi7h6v0k0kj-nixos-rebuild/bin/nixos-rebuild: No such file or directory
error: builder for '/nix/store/78mw9fbgdmn7jbpqkam53smy3jxhkpzz-nixos-rebuild.drv' failed with exit code 1
building Nix...
nix-instantiate: error while loading shared libraries: /nix/store/79lh7p2jjwqimzwksnpaclc3zj42zqda-openssl-1.1.1k/lib/libcrypto.so.1.1: file too short
building the system configuration...
nix-build: error while loading shared libraries: /nix/store/79lh7p2jjwqimzwksnpaclc3zj42zqda-openssl-1.1.1k/lib/libcrypto.so.1.1: file too short
root@tethys:~ # nix-store --repair-path /nix/store/79lh7p2jjwqimzwksnpaclc3zj42zqda-openssl-1.1.1k
copying path '/nix/store/79lh7p2jjwqimzwksnpaclc3zj42zqda-openssl-1.1.1k' from 'https://cache.nixos.org'...
root@tethys:~ # nixos-rebuild switch
this derivation will be built:
/nix/store/78mw9fbgdmn7jbpqkam53smy3jxhkpzz-nixos-rebuild.drv
building '/nix/store/78mw9fbgdmn7jbpqkam53smy3jxhkpzz-nixos-rebuild.drv'...
/nix/store/a9skvgykplgx882i0wgf3k4gqj7nm9i2-stdenv-linux/setup: line 754: /nix/store/wj4z7145vcph0mp3h78afvi7h6v0k0kj-nixos-rebuild/bin/nixos-rebuild: No such file or directory
error: builder for '/nix/store/78mw9fbgdmn7jbpqkam53smy3jxhkpzz-nixos-rebuild.drv' failed with exit code 1
building Nix...
nix-instantiate: error while loading shared libraries: /nix/store/0mb2vd16sclqn9h6gsm64il4hfiwgwn3-bzip2-1.0.6.0.2/lib/libbz2.so.1: file too short
building the system configuration...
nix-build: error while loading shared libraries: /nix/store/0mb2vd16sclqn9h6gsm64il4hfiwgwn3-bzip2-1.0.6.0.2/lib/libbz2.so.1: file too short
root@tethys:~ # nix-store --repair-path /nix/store/0mb2vd16sclqn9h6gsm64il4hfiwgwn3-bzip2-1.0.6.0.2/lib/libbz2.so.1
copying path '/nix/store/0mb2vd16sclqn9h6gsm64il4hfiwgwn3-bzip2-1.0.6.0.2' from 'https://cache.nixos.org'...
root@tethys:~ # nixos-rebuild switch
this derivation will be built:
/nix/store/78mw9fbgdmn7jbpqkam53smy3jxhkpzz-nixos-rebuild.drv
building '/nix/store/78mw9fbgdmn7jbpqkam53smy3jxhkpzz-nixos-rebuild.drv'...
/nix/store/a9skvgykplgx882i0wgf3k4gqj7nm9i2-stdenv-linux/setup: line 754: /nix/store/wj4z7145vcph0mp3h78afvi7h6v0k0kj-nixos-rebuild/bin/nixos-rebuild: No such file or directory
error: builder for '/nix/store/78mw9fbgdmn7jbpqkam53smy3jxhkpzz-nixos-rebuild.drv' failed with exit code 1
building Nix...
nix-instantiate: error while loading shared libraries: /nix/store/9xnwvyzm8x3d7kk3lsvy9wyjdf684x5w-zlib-1.2.11/lib/libz.so.1: file too short
building the system configuration...
nix-build: error while loading shared libraries: /nix/store/9xnwvyzm8x3d7kk3lsvy9wyjdf684x5w-zlib-1.2.11/lib/libz.so.1: file too short
root@tethys:~ # nix-store --repair-path /nix/store/9xnwvyzm8x3d7kk3lsvy9wyjdf684x5w-zlib-1.2.11/lib/libz.so.1
copying path '/nix/store/9xnwvyzm8x3d7kk3lsvy9wyjdf684x5w-zlib-1.2.11' from 'https://cache.nixos.org'...
root@tethys:~ # nixos-rebuild switch
this derivation will be built:
/nix/store/78mw9fbgdmn7jbpqkam53smy3jxhkpzz-nixos-rebuild.drv
building '/nix/store/78mw9fbgdmn7jbpqkam53smy3jxhkpzz-nixos-rebuild.drv'...
/nix/store/a9skvgykplgx882i0wgf3k4gqj7nm9i2-stdenv-linux/setup: line 754: /nix/store/wj4z7145vcph0mp3h78afvi7h6v0k0kj-nixos-rebuild/bin/nixos-rebuild: No such file or directory
error: builder for '/nix/store/78mw9fbgdmn7jbpqkam53smy3jxhkpzz-nixos-rebuild.drv' failed with exit code 1
building Nix...
nix-instantiate: error while loading shared libraries: /nix/store/g53fspaj03xks0zrknm4vbng04rcl5b1-acl-2.3.1/lib/libacl.so.1: file too short
building the system configuration...
nix-build: error while loading shared libraries: /nix/store/g53fspaj03xks0zrknm4vbng04rcl5b1-acl-2.3.1/lib/libacl.so.1: file too short
root@tethys:~ #
My current nixos system generation was working perfectly, but many - if not all - of the store dependencies of the new system derivation that I was trying to build were all messed up as described by @ajkachnic.
Basic dependencies like /nix/store/79lh7p2jjwqimzwksnpaclc3zj42zqda-openssl-1.1.1k/lib/libcrypto.so.1.1 were truncated to zero length. There were many .drv files in /nix/store which were empty. These prevented nix-store --verify --repair from working because Nix couldn’t parse an empty derivation.
Helped me continously repeating first command as @rvl suggested until /nix/store was free of empty derivations. Then was able to run rest commands successfully.
Similar problem happened due to full disk while ‘nixos-rebuild switch’.