I’ve been reading some articles regarding impermanence in NixOS, particularly this, this, this, and this, and I want to set up impermanence on my desktop system. Since it involves deleting my entire root, however, I figured I’d ask for advice here to learn what the best practices are for doing this to minimise risk of data loss, though it isn’t too critical since it’s a new setup. For reference, I have a Flake + home-manager setup on ZFS root, though I didn’t think to do a snapshot when the disk was empty since I didn’t know about impermanence when I started out. I also have separate ZFS datasets for /, /home, /nix, /var, and /var/lib. I want to set up impermanence for both root and home, with some persistent directories on home, but I’m not sure if I should set it up on both at once or if I should do root first and then home. Any advice or help is appreciated!

  • colinA
    link
    fedilink
    English
    arrow-up
    1
    ·
    1 year ago

    I’m assuming by “working offline” you mean booting into a live USB

    yeah, that’s one way. more generally, “offline” = any setup where the filesystem(s) you’re modifying to be impermanent isn’t critical to running whatever shell/session you’re using to do the work. that lets you do things in any order so long as the end state’s bootable, whereas moving /nix/store on a live system can totally just crash it and leave it unbootable if you’re not careful.

    Also, is that what the Impermanence repository does on the nix-community?

    default behavior for that impermanence repo is that persisted directories are mounted as bind mounts and persisted files are symlinks. that was chosen mostly to maximize out-of-the-box compatibility with most software out there, i believe. most people mount some fs to /nix during early boot, and place their persisted data in the persist/ subdirectory of that mount. but there’s a hundred different ways to do it: the other most common way is to use subvolumes and snapshots (btrfs, but maybe zfs can do it too?): / is one subvolume, and you take a snapshot where it’s empty; /nix is a subvolume where everything gets persisted. the Impermanence config that mounts stuff from /nix/persist into where you want it looks the same as it does with a tmpfs-on-root setup, and you get impermanence by just reverting / to that original snapshot on every boot.

    • ruination@discuss.tchncs.deOP
      link
      fedilink
      English
      arrow-up
      1
      ·
      edit-2
      1 year ago

      Yeah, ZFS can do it too, in fact I think that’s what Graham used in “Erase your darlings”. I’m thinking of just going the tmpfs root route, making a new dataset for /persist, and copying over the necessary files from my original root dataset, and using the impermanence module to take care of the rest of the work. That way, if I miss some files, I can just go back and copy them over from the root dataset to the persist dataset, and once I’m sure I got everything, I can just destroy the old root dataset. Would that be a good way to go about it?