Use an overlay for /etc instead of the current stateful approach
We could maybe use the same mechanism as what we have in nixos for mounting having /etc be an overlayfs with an immutable erofs image generated by system-manager as the lower layer, and the embedding OS' /etc folder as the upper, writable directory.
An entrypoint for the nixos implementation is https://github.com/NixOS/nixpkgs/blob/nixos-unstable/nixos/modules/system/etc/etc.nix
This idea is completely untested, so it may turn out not to work, but it's worth trying out.
The main advantage, is that we won't need to keep as much data (maybe none at all) in the state files, and that the whole process will be completely atomic and more performant.
Good idea.
One thing to validate is how well erofs is supported on other distros since it was added quite recently. squashfs might be a good fallback otherwise.