nix-community / impermanence

Modules to help you handle persistent state on systems with ephemeral root storage [maintainer=@talyz]
MIT License
1.14k stars 84 forks source link

The importance of persisting `/var/lib/nixos` is not documented #178

Closed kuruczgy closed 1 month ago

kuruczgy commented 6 months ago

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.

kuruczgy commented 6 months ago

Apparently this got recently documented in NixOS: https://github.com/NixOS/nixpkgs/pull/273384 We could just link to this in the README and the option docstring.

Guekka commented 4 months ago

Thank you for this issue. I had troubles with folders getting the wrong owner after a reboot and couldn't figure out why