[Nix-dev] How to fix corrupt .drv files in nix store?

Bjørn Forsman bjorn.forsman at gmail.com
Tue Jul 5 17:18:26 CEST 2016


Hi all,

Short version.
This doesn't work (what else can I try?):

$ sudo nix-store --verify --repair --check-contents
reading the Nix store...
checking path existence...
checking hashes...
path ‘/nix/store/1f0rxsgjcsdxj6jl6qaz555wcaxs164c-xsession.drv’ was
modified! expected hash
‘2e527f6df7f00f91be1a5f2a60c811a49e434b218f78096f7d020bf37b39fca3’,
got ‘77ac62e2629d8e45f624589c0c8bf99e24b3a722349bf1e79bc186008534e246’
error: cannot repair path
‘/nix/store/1f0rxsgjcsdxj6jl6qaz555wcaxs164c-xsession.drv’
...

Long version:
I wanted to see how atomic and safe a NixOS update process really is,
so I abused one of my systems by pulling the rootfs disk from it a
number of times duing "nixos-rebuild switch" (trying to simulate a
power cut-off at the worst possible time).

After a few rounds of testing, I ended up with empty, zero sized .drv
files, unable to do "nixos-rebuild":

$ sudo nixos-rebuild -I nixpkgs=. -Q build
building Nix...
building the system configuration...
error: error parsing derivation
‘/nix/store/h05l5cvr1lvk49vnii320kvpvfv6n1mf-nixos-system-nixos-on-usb-16.03.git.057421e.drv’:
expected string ‘Derive([’

$ ls -l /nix/store/h05l5cvr1lvk49vnii320kvpvfv6n1mf-nixos-system-nixos-on-usb-16.03.git.057421e.drv
-r--r--r-- 1 root root 0 Jan  1  1970
/nix/store/h05l5cvr1lvk49vnii320kvpvfv6n1mf-nixos-system-nixos-on-usb-16.03.git.057421e.drv

And, as you saw above, "sudo nix-store --verify --repair
--check-contents" didn't fix it.

Any suggestions?

When I get this system up again, I'll try with ext4 data=journal mount
option and see if that makes it more robust.

Best regards,
Bjørn Forsman


More information about the nix-dev mailing list