nix-community / impermanence

Modules to help you handle persistent state on systems with ephemeral root storage [maintainer=@talyz]
MIT License
1.14k stars 85 forks source link

bind home file or folder to some path, without the /home/<username> prefix in the NixOS module? #112

Closed quantenzitrone closed 1 year ago

quantenzitrone commented 1 year ago

I would like to bind /home/{documents, internet, music, videos, etc...} to /data/{documents, internet, music, videos, etc...}

Is that already possible? If yes how?

quantenzitrone commented 1 year ago
{
  # mounting the data partition
  fileSystems =
    {
      "/data" = {
        device = "/dev/disk/by-label/data";
        fsType = "ext4";
      };
    }
    # mapping the data folders into the users home folder
    // (builtins.listToAttrs (
      builtins.map (
        x: {
          name = "/home/${config.environment.variables.USERNAME}/" + x;
          value = {
            device = "/data/" + x;
            options = ["bind"];
            depends = ["/data"];
          };
        }
      ) [
        "documents"
        "internet"
        "music"
        "pictures"
        "videos"
      ]
    ));
}