Three Years of Ephemeral NixOS: My Experience Resetting Root on Every Boot

Date:

Fresh OS installs are bliss. But the joy fades quickly as installing and uninstalling programs leave behind a trail of digital debris. Even configuration management and declarative systems like NixOS miss crucial bits, like the contents of /var/lib or stray dotfiles. This debris isn’t just unsightly. It can be load-bearing, crucial to the functioning of your system, but outside of your control, and not preserved on rebuilds. Full system backups merely preserve this chaos. I wanted a clean slate, automatically, every boot.

“Erase your darlings” inspired an idea in the NixOS community: allowlisting files and directories that persist across reboots. Anything not on the list gets wiped. The simplest implementation involves mounting / as a tmpfs (i.e. in RAM), and then bind-mounting or symlinking the allowlisted items to a disk-backed filesystem.

This has been implemented for NixOS in the impermanence project, and has some support in Guix too. In NixOS, declaring this allowlist looks like:

environment.persistence."/mnt/btrfs/persistent" = {
  directories = [
    "/srv/git"
    "/var/lib/private/kea"
  ];
};

After three years of running this setup across my NixOS desktop, laptop, home NAS, router, and VPS, I’m sharing my experience. Below is a consolidated view of everything I persist across my machines (each has its own unique allowlist).

What survives the reboot

What doesn’t survive the reboot

Everything else, which includes things like:

(Note: /usr is absent on NixOS systems.)

What’s worked well

What’s worked poorly

Is it worth it?

Declarative machine management and ephemeral state has banished my anxiety about stateful systems, a huge win. But this peace of mind comes at a cost: time. Ironically, despite aiming for less upkeep, I likely spend more time than users of conventional systems.

My aim is to simplify maintenance. While abandoning impermanence entirely (or switching to something like Fedora Silverblue) is an option, I’m taking a more gradual approach: expanding what I persist, starting with my Firefox profile. I’ll share my experience with ephemeral Firefox soon.