impermanence
impermanence copied to clipboard
The importance of persisting `/var/lib/nixos` is not documented
The examples do show /var/lib/nixos
being persisted, but it's never mentioned that doing so is vital to the correct functioning of the UID/GID allocation mechanism of NixOS.
If /var/lib/nixos
is not persisted, UIDs/GIDs are allocated sequentially, and so can shift around across boots if new ones are added to the configuration. It can happen that after a reboot, a file is now randomly owned by a different user.
The documentation should warn about this, and as a longer term solution I would suggest adding an assertion: Only allow /var/lib/nixos
to not be persisted if all users/groups have explicitly declared ids.