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

Home persistence bug, maybe? #98

Closed ghost closed 2 years ago

ghost commented 2 years ago

I setuped the my home persistence with environment.persistence.{state}, then I use home-manager to configuring my home environment with home.persistence.{home state}, after home config switched and reboot, my home config disappear

hosts/local/default.nix:

...
programs.fuse.userAllowOther = true;
environment.persistence."/persist" = {
  directories = [ "/var/log" ];
  files = [ "/etc/machine-id" ];
};
...

user/c4droid/default.nix:

...
programs.zsh = {
  enable = true;
};
home.persistence."/persist/home/c4droid" = {
  allowOther = true;
  files = [ ".zshenv" ];
};
home.homeDirectory = "/home/c4droid";
...

After switching, the directroy contain:

ls -l
total 8
drwx------ 8 c4droid users 260 Jul 13 17:46 .
drwxr-xr-x 3 root    root   60 Jul 13 17:28 ..
drwx------ 4 c4droid users 100 Jul 13 17:45 .cache
drwxr-xr-x 6 c4droid users 120 Jul 13 17:45 .config
-rw------- 1 c4droid users  20 Jul 13 17:34 .lesshst
drwx------ 3 c4droid users  60 Jul 13 17:30 .local
drwxr-xr-x 2 c4droid users  80 Jul 13 17:45 .nix-defexpr
lrwxrwxrwx 1 c4droid users  46 Jul 13 17:45 .nix-profile -> /nix/var/nix/profiles/per-user/c4droid/profile
drwxr-xr-x 1 c4droid users  10 Jul 13 16:09 project
drwxr-xr-x 1 c4droid users   0 Jul 13 16:06 .ssh
lrwxrwxrwx 1 c4droid users  70 Jul 13 17:45 .zshenv -> /nix/store/j79mwpkldkrvigi1l4z2wzy62fvwracg-home-manager-files/.zshenv
-rw------- 1 c4droid users  61 Jul 13 17:46 .zsh_history
lrwxrwxrwx 1 c4droid users  69 Jul 13 17:45 .zshrc -> /nix/store/j79mwpkldkrvigi1l4z2wzy62fvwracg-home-manager-files/.zshrc

After rebooting, the directory contain:

ls -l
total 0
drwx------ 2 c4droid users 40 Jul 13 17:48 .
drwxr-xr-x 3 root    root  60 Jul 13 17:48 ..

I tried use environment.persistence.{state directory}.users.{username} which home-manager, after I switch new system and home config and reboot, my home directory .nix-profile and .nix-defexpr disappear

talyz commented 2 years ago

In order for the home-manager module to work properly, you need to use the home-manager NixOS module (see the Important note part of the home-manager section of the readme). You could also opt to use the users.* option of the NixOS module to handle user files without relying on home-manager.