/nix/store corrupted

My laptop battery died overnight, and I believe this corrupted my /nix/store. Perhaps it was doing something nixy?

When I attempt to run sudo nixos-rebuild boot I receive the following error:

error: error parsing derivation '/nix/store/iah2rxqabr79ng4y15ppllg584m47apv-kernel-modules.drv': expected string 'Derive(['

Some Googling turned up this nix-env being aborted bricks try to run it again · Issue #1218 · NixOS/nix · GitHub

I have run sudo nix-store --verify --check-contents --repair several times. I was thinking it might be convergent, but it has now converged to the same errors:

reading the Nix store...
checking path existence...
checking hashes...
path '/nix/store/08yrb9f5k3s0vbq3x8byz9lmh3rb1jwy-dbus-1.drv' was modified! expected hash 'sha256:0ck8jv8qj6zgwzi900mqnzyqrqlri9s2q1vzbnwcr3rbmgf55xvw', got 'sha256:0ip26j2h11n1kgkz36rl4akv694yz65hr72q4kv4b3lxcbi65b3p'
error: cannot repair path '/nix/store/08yrb9f5k3s0vbq3x8byz9lmh3rb1jwy-dbus-1.drv'
path '/nix/store/0cbwk39i3xw0lmvf0bh7fsbgg9b5mdkc-unit-cpufreq.service.drv' was modified! expected hash 'sha256:0xha7xpggmxg2p9wp9gix044lfa43mcld571f4l0i0cwmbykqfzg', got 'sha256:0ip26j2h11n1kgkz36rl4akv694yz65hr72q4kv4b3lxcbi65b3p'
error: cannot repair path '/nix/store/0cbwk39i3xw0lmvf0bh7fsbgg9b5mdkc-unit-cpufreq.service.drv'
path '/nix/store/2di8c2gbbbw3wvkkw24nfidvldp76kb9-unit-cpufreq.service' was modified! expected hash 'sha256:167w3kwm8n7n6a4ikpipgpq0scvipbhg92rnv5l5awd04qbi8x3w', got 'sha256:0dx5bc4dzv1p5aab5s37bnys84vwlcgydq3pfv4382nmh5jq8rp7'
error: error parsing derivation '/nix/store/0cbwk39i3xw0lmvf0bh7fsbgg9b5mdkc-unit-cpufreq.service.drv': expected string 'Derive(['
path '/nix/store/4hzz95syz8z2z58z4n2988d0ssc9lhhz-unit-foundationdb.service.drv' was modified! expected hash 'sha256:15q4im8q98brhqw1j7fzhggr0xnr3qr80rcfskdmnmwaxq08a1jq', got 'sha256:0ip26j2h11n1kgkz36rl4akv694yz65hr72q4kv4b3lxcbi65b3p'
error: cannot repair path '/nix/store/4hzz95syz8z2z58z4n2988d0ssc9lhhz-unit-foundationdb.service.drv'
path '/nix/store/8bv7c0dfymflryzp56cl6fqscfpsxs5f-system-units.drv' was modified! expected hash 'sha256:06p9cl1gfl7ha0yn9lbajdx99izzbkhh61zacj5na33rsbxfqs15', got 'sha256:0ip26j2h11n1kgkz36rl4akv694yz65hr72q4kv4b3lxcbi65b3p'
error: cannot repair path '/nix/store/8bv7c0dfymflryzp56cl6fqscfpsxs5f-system-units.drv'
path '/nix/store/9240gjg1qkv2jad0nsjd4f4dpx97ccj6-nixos-system-carbon-20.03.3236.2257e6cf4d7.drv' was modified! expected hash 'sha256:07iadlr0xm9nka80k66j3i5hyy670j7idlgxp6knas4b5fj4l69n', got 'sha256:0ip26j2h11n1kgkz36rl4akv694yz65hr72q4kv4b3lxcbi65b3p'
error: cannot repair path '/nix/store/9240gjg1qkv2jad0nsjd4f4dpx97ccj6-nixos-system-carbon-20.03.3236.2257e6cf4d7.drv'
path '/nix/store/9mfi9w6xbll8r8392jg960vmpsf7sjmm-etc-os-release.drv' was modified! expected hash 'sha256:1fqnnbbpprbh6liv1zakwny612pkzz4k8mwdb3f0pf4d4gvk25q5', got 'sha256:0ip26j2h11n1kgkz36rl4akv694yz65hr72q4kv4b3lxcbi65b3p'
error: cannot repair path '/nix/store/9mfi9w6xbll8r8392jg960vmpsf7sjmm-etc-os-release.drv'
path '/nix/store/cf22iscnpyai5gsz045p29yyyc2532wi-unit-dbus.service.drv' was modified! expected hash 'sha256:08pb01rxgipv6n7g3k82wx0rrmjx1a2rfkpiq037lh4rad4z39hn', got 'sha256:0ip26j2h11n1kgkz36rl4akv694yz65hr72q4kv4b3lxcbi65b3p'
error: cannot repair path '/nix/store/cf22iscnpyai5gsz045p29yyyc2532wi-unit-dbus.service.drv'
path '/nix/store/cfyan6zq13vyd1sx5922rpx7cfasz17j-etc.drv' was modified! expected hash 'sha256:0rflbbnjbqlpkq86p1shbxvrg08yb0m7icqy9kvy4kn3pb9f21sc', got 'sha256:0ip26j2h11n1kgkz36rl4akv694yz65hr72q4kv4b3lxcbi65b3p'
error: cannot repair path '/nix/store/cfyan6zq13vyd1sx5922rpx7cfasz17j-etc.drv'
path '/nix/store/dc0ymy86lbd1020gkaq6xz2ibx81n3fn-system-generators.drv' was modified! expected hash 'sha256:1w3w1lfvf9iyav5mlsmis4zjg5s2g055r0pp6fvdsqvhimjvkm5h', got 'sha256:0ip26j2h11n1kgkz36rl4akv694yz65hr72q4kv4b3lxcbi65b3p'
error: cannot repair path '/nix/store/dc0ymy86lbd1020gkaq6xz2ibx81n3fn-system-generators.drv'
path '/nix/store/g3bpwwbn5abp1pmch99czb340r687vad-issue.drv' was modified! expected hash 'sha256:0qg6sjyvh3cjzbkm3l1nx2yx0hrdvx8m2kiv4q3r6xp7kr9ixn60', got 'sha256:0ip26j2h11n1kgkz36rl4akv694yz65hr72q4kv4b3lxcbi65b3p'
error: cannot repair path '/nix/store/g3bpwwbn5abp1pmch99czb340r687vad-issue.drv'
path '/nix/store/hx5k5qqwzxgdvcjmhv0ylha3hy1n3sfs-unit-accounts-daemon.service.drv' was modified! expected hash 'sha256:1rk8mlj2ai9kq9cfwflmr9cky96vfzvzc3gm75j4zpcv9v8j88sa', got 'sha256:0ip26j2h11n1kgkz36rl4akv694yz65hr72q4kv4b3lxcbi65b3p'
error: cannot repair path '/nix/store/hx5k5qqwzxgdvcjmhv0ylha3hy1n3sfs-unit-accounts-daemon.service.drv'
path '/nix/store/iah2rxqabr79ng4y15ppllg584m47apv-kernel-modules.drv' was modified! expected hash 'sha256:0xb1y0l4fv8bq2dayhqsdzjhai3q99rf34mh6a534cavfq1pxwwj', got 'sha256:0ip26j2h11n1kgkz36rl4akv694yz65hr72q4kv4b3lxcbi65b3p'
error: cannot repair path '/nix/store/iah2rxqabr79ng4y15ppllg584m47apv-kernel-modules.drv'
path '/nix/store/jfiqwcijw76f5qn26v622lfsj1y9mrnq-linux-5.4.75-modules-shrunk.drv' was modified! expected hash 'sha256:0qi7766pa87pcmhzzgxfhcpf976pkkmsyia4nxwp72qwcn23qi1y', got 'sha256:0ip26j2h11n1kgkz36rl4akv694yz65hr72q4kv4b3lxcbi65b3p'
error: cannot repair path '/nix/store/jfiqwcijw76f5qn26v622lfsj1y9mrnq-linux-5.4.75-modules-shrunk.drv'
path '/nix/store/lwi7bpw84rc7m58dr3jvyasinyffqy7a-etc-profile.drv' was modified! expected hash 'sha256:19lrxpv6swypj99a48s6s6ijhxcmsifrmh78vki8fn49v5d4wc9j', got 'sha256:0ip26j2h11n1kgkz36rl4akv694yz65hr72q4kv4b3lxcbi65b3p'
error: cannot repair path '/nix/store/lwi7bpw84rc7m58dr3jvyasinyffqy7a-etc-profile.drv'
path '/nix/store/mr4fq5dwpyzrqnkq2gcggfaar9dnr72f-user-units.drv' was modified! expected hash 'sha256:0xrfp5gcy7s54mp10xnq8czv0j3inda8fl7zqa8xmcvxkfbfi66f', got 'sha256:0ip26j2h11n1kgkz36rl4akv694yz65hr72q4kv4b3lxcbi65b3p'
error: cannot repair path '/nix/store/mr4fq5dwpyzrqnkq2gcggfaar9dnr72f-user-units.drv'
path '/nix/store/nw8hhss6f99pwkx5ij3w248545gd31vx-unit-dbus.service.drv' was modified! expected hash 'sha256:12bdbvama6rccq2pv9jx4k9d77cy04dqsiypsfniz3ipq82s6d7p', got 'sha256:0ip26j2h11n1kgkz36rl4akv694yz65hr72q4kv4b3lxcbi65b3p'
error: cannot repair path '/nix/store/nw8hhss6f99pwkx5ij3w248545gd31vx-unit-dbus.service.drv'
path '/nix/store/pkxgw7aax8692plw2wjdfk349lpdqhj8-unit-polkit.service.drv' was modified! expected hash 'sha256:0mcbiwq7kdcf400ixjkyf7mcb0v98hq9ch8qr9yx44j8q65dhpc9', got 'sha256:0ip26j2h11n1kgkz36rl4akv694yz65hr72q4kv4b3lxcbi65b3p'
error: cannot repair path '/nix/store/pkxgw7aax8692plw2wjdfk349lpdqhj8-unit-polkit.service.drv'
path '/nix/store/q0n0623rirmc7f0w2v0hx874sa8nr7a0-system-shutdown.drv' was modified! expected hash 'sha256:0arlnmh4ds7h25addc1b6c7fxgsppsycbdpvhlcmcvhp50m8ipf5', got 'sha256:0ip26j2h11n1kgkz36rl4akv694yz65hr72q4kv4b3lxcbi65b3p'
error: cannot repair path '/nix/store/q0n0623rirmc7f0w2v0hx874sa8nr7a0-system-shutdown.drv'
path '/nix/store/r337qyhhjb89gpi463pn7whfy6f2a3am-linux-5.4.75-modules.drv' was modified! expected hash 'sha256:1smjf3h1swym21c6n9sw19xpqnz1bqcj413vvmq151js0d7slcpf', got 'sha256:0ip26j2h11n1kgkz36rl4akv694yz65hr72q4kv4b3lxcbi65b3p'
error: cannot repair path '/nix/store/r337qyhhjb89gpi463pn7whfy6f2a3am-linux-5.4.75-modules.drv'
path '/nix/store/w1kdkmvraz9irczv41mqfhmg73fmp22x-unit-systemd-fsck-.service.drv' was modified! expected hash 'sha256:17jx8q4fwfcrpj1qg787ywficdrnb91g0gds8hb3q6406mfyzkd4', got 'sha256:0ip26j2h11n1kgkz36rl4akv694yz65hr72q4kv4b3lxcbi65b3p'
error: cannot repair path '/nix/store/w1kdkmvraz9irczv41mqfhmg73fmp22x-unit-systemd-fsck-.service.drv'
path '/nix/store/wn3qibwkpjkp75h1g0k1js295bdy2f6g-set-environment.drv' was modified! expected hash 'sha256:1rl86rbx5065dj7vhnwpy2ilrfalb3ckw4qwznshk6lhb3s6z3m9', got 'sha256:0ip26j2h11n1kgkz36rl4akv694yz65hr72q4kv4b3lxcbi65b3p'
error: cannot repair path '/nix/store/wn3qibwkpjkp75h1g0k1js295bdy2f6g-set-environment.drv'
path '/nix/store/xybnh95ca0fd528liqc3sf9halmga8sh-stage-1-init.sh.drv' was modified! expected hash 'sha256:17nr5q2qd50574s756bjkdb4x63yccy9j8hpxdhc1xmfdspklsmk', got 'sha256:0ip26j2h11n1kgkz36rl4akv694yz65hr72q4kv4b3lxcbi65b3p'
error: cannot repair path '/nix/store/xybnh95ca0fd528liqc3sf9halmga8sh-stage-1-init.sh.drv'
path '/nix/store/y436bjm56m751hdmmh3p60k16n17dfjb-initrd-linux-5.4.75.drv' was modified! expected hash 'sha256:1rnanix52zijnvqzyykf0rddd86dgwllbrwp3f3a77zhkhxwkycw', got 'sha256:0ip26j2h11n1kgkz36rl4akv694yz65hr72q4kv4b3lxcbi65b3p'
error: cannot repair path '/nix/store/y436bjm56m751hdmmh3p60k16n17dfjb-initrd-linux-5.4.75.drv'
path '/nix/store/zrlr02aqghdv6m1v2qkqcl9vjczvw7v1-etc-nixos.conf.drv' was modified! expected hash 'sha256:0bd8j7k8qdvh70pqqp0p4ypwzgfq809hyi7ajxrdlzvdn4dxqp5z', got 'sha256:0ip26j2h11n1kgkz36rl4akv694yz65hr72q4kv4b3lxcbi65b3p'
error: cannot repair path '/nix/store/zrlr02aqghdv6m1v2qkqcl9vjczvw7v1-etc-nixos.conf.drv'
warning: not all errors were fixed

For now, my laptop seems to boot OK, but I don’t think it’s configuration is perfect, so I’ll want to do some kind of nixos-rebuild.

Is there some way to force nix to just rebuild my whole store from scratch? Or should I try something else?

Thanks!

Have you also checked the filesytem /nix/store is on for errors?

I ran nix-collect-garbage and then nixos-rebuild boot and it worked, so I guess that resolved my problem.

1 Like