diff options
Diffstat (limited to 'layers/nix.nix')
| -rw-r--r-- | layers/nix.nix | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/layers/nix.nix b/layers/nix.nix index 02c37ac..f4dc07f 100644 --- a/layers/nix.nix +++ b/layers/nix.nix @@ -61,9 +61,13 @@ in # overlay, deleting a lower layer's path leaves a whiteout in the rw-store, # or an opaque directory, which is what nix adds again, if it gets that # far. With a persistent rw-store, that hides the path from any - # later image, too. Any path that a lower layer has is complete - # there, and the same as anything of that name in the rw-store, so - # drop such paths from the rw-store before mounting the overlay. + # later image, too. Any path that an image has is complete there, and + # the same as anything of that name in the rw-store, so drop such paths + # from the rw-store before mounting the overlay. Not so for the host's + # store, which can lose a path any time (its garbage collection), while + # the guest's nix still has it registered (then nix-store --verify + # fails): drop only whiteouts, which would hide the host's path, and + # keep real copies. boot.initrd.systemd.services.fc-rw-store-unshadow = { requiredBy = [ "sysroot-nix-store.mount" ]; before = [ "sysroot-nix-store.mount" ]; @@ -74,12 +78,17 @@ in mkdir -p -m 0755 /sysroot/nix/.rw-store/store /sysroot/nix/.rw-store/work cd /sysroot/nix/.rw-store/store for p in *; do - for d in ${toString (map (d: "/sysroot" + d) lowerdir)}; do + for d in ${toString (map (d: "/sysroot" + d) (lib.remove "/nix/.host-store" lowerdir))}; do if test -e "$d/$p"; then rm -rf "$p" - break + continue 2 fi done + # Whiteouts (character devices, which no store path is) hide the + # host's path, or nothing. + if test -c "$p"; then + rm -f "$p" + fi done ''; }; |
