Repository navigation
Conversation
Review dismissed automatically
|
Nice! I'll test it either tonight or sometime this weekend. |
RossSmyth
left a comment
There was a problem hiding this comment.
It is acting as I expect it to:
run0 rm /etc/nixos/nixpkgs- nixos-rebuild .......
- ls /etc/nixos
and the symlink is back.
Then it also didn't mess with NetworkManager, which is another worry I have with /etc things, as if I enable an immutable /etc, nm doesn't work as it cannot place files in /etc.
Same thing when I restart my computer. It places the /etc/nixos/nixpkgs symlink back, and wifi still works.
3198d46 to
c980646
Compare
|
I've not tested it, but I've come across another issues where switching to resolved does not symlink |
Replace the find-etc and clear-etc-opaque entrypoints with two new ones that call into a shared setup_etc(): initrd-etc-overlay (discovers the layout from bootspec) and mount-etc-overlay (takes it on the CLI for activation/nixos-enter). The overlay and erofs metadata are built as detached mounts, with file-backed erofs and fd-based lowerdir+ on recent kernels and losetup / path-based lowerdir as fallbacks. When /etc is already mounted, the new overlay is slid beneath it and the old one is detached. The upperdir reconciler now also removes whiteouts and copied-up files that shadow nixos-managed entries, so deleting or replacing a managed /etc entry at runtime no longer hides it permanently. Fixes NixOS#505475
Reconciling the upperdir of the live /etc overlay during switch is undefined behaviour since we mess with the state of a live overlayfs. We already get a kernel warning in the logs because of the shared upperdir between the two overlayfs mounts. It also risks losing user replacements of managed files if activation crashes before the new mount is revealed. Instead, take a hardlink-tree snapshot at /.rw-etc/upper.next, reconcile and mount against that, and promote it with RENAME_EXCHANGE after the new overlay is in place. A crash at any point leaves the canonical /.rw-etc/upper untouched. The initrd path keeps reconciling in place since nothing has the upperdir mounted there.
c980646 to
84ed6c1
Compare
|
I do not use mutable etc anymore, but it would still be good to see this. It did work back when I did have a mutable etc, but I would like to get some eyes on some of the changes besides just me before merging. |
Things done
Rewrite the overlay /etc mounting logic in Rust as part of nixos-init, replacing the existing bash implementation.
Because:
nixos-init activateThis also fixes the mutable overlay switch logic.
Previously, switching between generations reused the live upperdir and combined it with a new lowerdir.
The kernel warns about this because sharing the upperdir of a mounted overlayfs is undefined behaviour, and the upperdir state can get out of sync with the lowerdir.
We also touched the live upperdir in place, so a crash mid-switch could leave it in a half-cleaned state.
In practice this meant that once a managed /etc file or directory was deleted or modified at runtime, overlayfs left whiteouts, opaque markers, or copied-up files in the upperdir that kept shadowing the declaratively managed version across rebuilds, with no practical way for a user to get back to it or even see what happened (see for instance #505475).
The old cleanup only handled the opaque case.
The new behaviour on live switch:
A crash at any point leaves the original upperdir untouched.
In initrd we keep reconciling in place since nothing has the upperdir mounted at that point.
Fixes #505475
passthru.tests.nixpkgs-reviewon this PR. See nixpkgs-review usage../result/bin/.