Skip to content

User persistence configuration

The persistence system is opt-in: only explicitly listed paths survive a reboot. Everything else is wiped.

System-level persistence

The system persists only the paths required for boot:

  • /var/lib/nixos -- NixOS state.
  • /etc/ssh -- SSH host keys (prevents client trust warnings on reconnect).
  • /etc/machine-id -- system machine identifier.

User-level persistence

Configure persistence per user through Home Manager:

{...}: {
  imports = [
    ../../modules/home-manager/core
  ];

  # Configure what you want to persist
  persistence = {
    enable = true;

    directories = [
      # Essential user configs
      ".ssh"
      ".config/sops"

      # Work directories
      "Projects"
      "Documents"
      "Downloads"

      # Application data
      ".local/share/direnv"
      ".cache/nix"
    ];

    files = [
      ".bash_history"
      ".gitconfig"
    ];
  };
}

Multi-user support

Each user controls their own persistence independently:

# User 1 - Minimal persistence
persistence = {
  enable = true;
  directories = [ ".ssh" "Documents" ];
  files = [ ".bash_history" ];
};

# User 2 - Full persistence
persistence = {
  enable = true;
  directories = [
    ".ssh" "Projects" "Documents" "Downloads"
    ".config" ".local/share" ".cache"
  ];
  files = [ ".bash_history" ".gitconfig" ".vimrc" ];
};

Platform support

Platform Status
NixOS Full persistence with impermanence
r2d2 (VM) Conditional, enabled when /persist filesystem exists

Add a persistence path

Add the path to your persistence configuration and rebuild:

persistence = {
  enable = true;
  directories = [
    # Add new directory
    ".mozilla"  # Firefox profiles
  ];
  files = [
    # Add new file
    ".zsh_history"
  ];
};

The system creates bind mounts and persists the data across reboots.