Hello, I see some people have ephemeral root working. Without having this set up, is there a list of what paths need to be backed up to recreate my system?
I’m already using a flake in my home for building the the system, but I guess I still need /etc for things like the shadow file. Do I need all of /var minus /var/cache? I guess I’ll also want to exclude /var/run/booted-system and /var/run/current-system.
Anyway, I think you get what I’m asking. One of NixOS’s selling points to me was I can revert to previous generations easily. I’d like the same with my backups without having to back up the world.
You can trivially try this out by just mounting your / as a tmpfs instead of your actual storage. This practically emulates full data loss. You’ll quickly notice which pieces of state you would be missing.
Depending on what kind of services you’re running, you might only need a few files of state here and there. Definitely not all of /etc and/or /var.
I built my system as inspired by Erase your Darlings. During boot, my root filesystem is effectively erased. Then root is built from persistent versions of /boot, /nix, /etc/nixos and /etc/NetworkManager/system-connections (for wifi memory).
Additionally, I use a separate fs mount for /var/log because I want to persist past boot logs. For that to be properly useful, /etc/machine-id must be persistent, too.
I have a persistent /etc/gitconfig that I should migrate into configuration.nix. If I used bluetooth more often, I’d need to keep its state around (or construct it in the store).
So, really there is almost nothing that that must be persistent that cannot be put in config (and the store). It just takes some tuning.
When I tell my colleagues about this approach, they says things like “gosh, rebuild the OS on every boot? that must be slow.” My laptop boots in about 22 seconds, spending 13s of that running firmware (before the OS bootloader).