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

Opt-in Mirror Mode #186

Open dmadisetti opened 4 months ago

dmadisetti commented 4 months ago

I'd like something less restrictive than explicit declaration, but still opt-in. Here's my idea

{
  environment.persistence."/persistent" = {
    hideMounts = true;
    ...

    users.talyz = {
         mirrored = true;
    };
  };
}

mirror mode sets a sticky group on directories- let's say the default is forgetful. The feature should also come with a helper script remember.

The remember script, moves the file/ folder to the persistent path, and changes the group to something not forgetful (default users), and mounts / symlinks.

On clean, all files with the forgetful group are pruned. Empty forgetful directories are pruned. On boot, just mount everything declared mirror in the persistence equivalent path.

Let me know if this is a won't fix, and I'll just keep my implementation to myself.