nix-community / impermanence

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

Folders are only bound/mount after home-manager switch #104

Closed rodrgz closed 1 year ago

rodrgz commented 1 year ago

I am using Impermanence in / and /home/, both created as tmpfs. For / is working correctly. But after reboot, for /home/user, the folders are empty, being linked only after using a "home-manager switch --flake ." .

It seems that systemd services to bindMount are only started after home-manager, and the "systemd enable" is not kept for the next boot.

imports = [ inputs.impermanence.nixosModules.home-manager.impermanence ];

home = { username = lib.mkDefault "erik"; homeDirectory = lib.mkDefault "/home/${config.home.username}"; stateVersion = lib.mkDefault "22.05";

persistence = {
  "/persist/home/erik" = {
    directories = [
      "documents"
      "downloads"
      "pictures"
      "videos"
      "mega"
      "notes"
      "projects"
      ".local/share/containers"
      ".local/share/flatpak"
      ".cache/flatpak"
    ];
    allowOther = true;
  };
};

};

talyz commented 1 year ago

Hi! If you want to use the home-manager module, you have to run home-manager through its NixOS module or it won't work as intended. See the note at https://github.com/nix-community/impermanence#home-manager.

rodrgz commented 1 year ago

I found the error. I am using loginShellInit = '' [ -d "$HOME/.nix-profile" ] || /nix/var/nix/profiles/per-user/$USER/home-manager/activate &> /dev/null ''; to activate home-manager environment, some of the steps inside the script are causing errors and are not related to impermanence. The activate script uses "set -e". Just one thing to note, is that using activate, folders are first created and mounted, then unmounted and remounted by systemd bindMount services.