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

home-manager bind mounts gone missing. #130

Open reedrw opened 1 year ago

reedrw commented 1 year ago

Lately sometimes whenever I boot my computer, some or all of my home-manager bind mounts fail to be created. This can always be fixed by running sudo systemctl restart home-manager-$USER.service, but I have no idea why it's happening.

systemctl status home-manager-$USER.service seems to show nothing out of the ordinary at reboot

● home-manager-reed.service - Home Manager environment for reed
     Loaded: loaded (/etc/systemd/system/home-manager-reed.service; enabled; preset: enabled)
     Active: active (exited) since Sun 2023-06-11 11:50:42 EDT; 38s ago
    Process: 1428 ExecStart=/nix/store/0yiywc863z3ipsmm3aj3k9y2k8cf6s7i-hm-setup-env /nix/store/ys68amm0af0cc74vhagpifwwbz01fvid-home-manager-generation (code=exited, status=0/SUCCESS)
   Main PID: 1428 (code=exited, status=0/SUCCESS)
         IP: 0B in, 0B out
        CPU: 1.207s

Jun 11 11:50:41 nixos-desktop hm-activate-reed[2109]: dbus-daemon[2109]: [session uid=1000 pid=2109] Activating service name='ca.desrt.dconf' requested by ':1.0' (uid=1000 pid=2110 comm="/nix/store/y48b9yasmsylly0sn1aqqkswqcaxpgzf-dconf-" label="kernel")
Jun 11 11:50:41 nixos-desktop hm-activate-reed[2109]: dbus-daemon[2109]: [session uid=1000 pid=2109] Successfully activated service 'ca.desrt.dconf'
Jun 11 11:50:41 nixos-desktop hm-activate-reed[1428]: Activating linkGeneration
Jun 11 11:50:41 nixos-desktop hm-activate-reed[1428]: Creating profile generation 1
Jun 11 11:50:41 nixos-desktop hm-activate-reed[1428]: Creating home file links in /home/reed
Jun 11 11:50:42 nixos-desktop hm-activate-reed[1428]: Activating onFilesChange
Jun 11 11:50:42 nixos-desktop hm-activate-reed[1428]: Activating runUnmountPersistentStoragePaths
Jun 11 11:50:42 nixos-desktop hm-activate-reed[1428]: Activating reloadSystemd
Jun 11 11:50:42 nixos-desktop hm-activate-reed[1428]: User systemd daemon not running. Skipping reload.
Jun 11 11:50:42 nixos-desktop systemd[1]: Finished Home Manager environment for reed.

Note that, at this point, none of the bind mounts are mounted even though the generation seems to have been successfully activated.

After restarting the service, they are mounted

● home-manager-reed.service - Home Manager environment for reed
     Loaded: loaded (/etc/systemd/system/home-manager-reed.service; enabled; preset: enabled)
     Active: active (exited) since Sun 2023-06-11 11:51:53 EDT; 3s ago
    Process: 3937 ExecStart=/nix/store/0yiywc863z3ipsmm3aj3k9y2k8cf6s7i-hm-setup-env /nix/store/ys68amm0af0cc74vhagpifwwbz01fvid-home-manager-generation (code=exited, status=0/SUCCESS)
   Main PID: 3937 (code=exited, status=0/SUCCESS)
         IP: 0B in, 0B out
         IO: 6.3M read, 36.0K written
      Tasks: 1 (limit: 19102)
     Memory: 7.2M
        CPU: 1.548s
     CGroup: /system.slice/home-manager-reed.service
             └─4232 /nix/store/5l2jrnd085ysfcdla46j4x9308w2mfiq-bindfs-1.17.2/bin/bindfs -o fsname=/persist/reed/.config/dconf /persist/reed/.config/dconf /home/reed/.config/dconf

Jun 11 11:51:51 nixos-desktop hm-activate-reed[3937]: The user systemd session is degraded:
Jun 11 11:51:51 nixos-desktop hm-activate-reed[5005]:   UNIT        LOAD   ACTIVE SUB    DESCRIPTION
Jun 11 11:51:51 nixos-desktop hm-activate-reed[5005]: ● mpd.service loaded failed failed Music Player Daemon
Jun 11 11:51:51 nixos-desktop hm-activate-reed[5005]: LOAD   = Reflects whether the unit definition was properly loaded.
Jun 11 11:51:51 nixos-desktop hm-activate-reed[5005]: ACTIVE = The high-level unit activation state, i.e. generalization of SUB.
Jun 11 11:51:51 nixos-desktop hm-activate-reed[5005]: SUB    = The low-level unit activation state, values depend on unit type.
Jun 11 11:51:51 nixos-desktop hm-activate-reed[5005]: 1 loaded units listed.
Jun 11 11:51:51 nixos-desktop hm-activate-reed[3937]: Attempting to reload services anyway...
Jun 11 11:51:52 nixos-desktop hm-activate-reed[5006]: Starting: clipboard-clean.service lorri-notify.service lorri.service mpd-mpris.service mpd.service mpv-dnd.service playerctld.service shairport-sync.service bindMount--persist-reed-cache-lorri-.service bindMount--persist-reed-cache-mesa_shader_cache-.service bindMount--persist-reed-cache-mozilla-.service bindMount--persist-reed-cache-mpv-.service bindMount--persist-reed-cache-nix-.service bindMount--persist-reed-cache-pre-commit-.service bindMount--persist-reed-cache-ranger-.service bindMount--persist-reed-config-BetterDiscord-.service bindMount--persist-reed-config-Mullvad-VPN-.service bindMount--persist-reed-config-cachix-.service bindMount--persist-reed-config-coc-.service bindMount--persist-reed-config-dconf-.service bindMount--persist-reed-config-discord-.service bindMount--persist-reed-config-easyeffects-.service bindMount--persist-reed-config-gh-.service bindMount--persist-reed-config-htop-.service bindMount--persist-reed-config-nixpkgs-.service bindMount--persist-reed-config-obs-studio-.service bindMount--persist-reed-local-share-PrismLauncher-.service bindMount--persist-reed-local-share-Steam-.service bindMount--persist-reed-local-share-TelegramDesktop-.service bindMount--persist-reed-local-share-anime-game-launcher-.service bindMount--persist-reed-local-share-direnv-.service bindMount--persist-reed-local-share-honkers-railway-launcher-.service bindMount--persist-reed-local-share-ranger-.service bindMount--persist-reed-local-state-wireplumber-.service bindMount--persist-reed-mozilla-firefox-.service bindMount--persist-reed-ssh-.service polybar.service
Jun 11 11:51:53 nixos-desktop systemd[1]: Finished Home Manager environment for reed.

I have systemd.user.startServices = true in my home.nix

reedrw commented 1 year ago

Moving my directory mounts into my system config works, but I'm not really sure why it didn't work sometimes with the home-manager module. Maybe some race condition?

talyz commented 1 year ago

When this happens, do you see the systemd user units for the mounts? If so, what is their log output?

n3oney commented 7 months ago

I have the same thing happening whenever I start waydroid, however the directories do not come back when I restart home-manager-<user>.service

The user units are still there:

❯ systemctl --user status bindMount--persist-home-neoney-nixus-.service 
○ bindMount--persist-home-neoney-nixus-.service - Bind mount '/persist/home/neoney/nixus' at '/home/neoney/nixus'
     Loaded: loaded (/home/neoney/.config/systemd/user/bindMount--persist-home-neoney-nixus-.service; enabled; preset: enabled)
     Active: inactive (dead) since Sat 2023-12-30 14:41:55 CET; 1min 41s ago
   Duration: 2min 672ms
   Main PID: 3317 (code=exited, status=0/SUCCESS)
        CPU: 38ms

Dec 30 14:39:54 miko systemd[3029]: Starting Bind mount '/persist/home/neoney/nixus' at '/home/neoney/nixus'...
Dec 30 14:39:54 miko systemd[3029]: Started Bind mount '/persist/home/neoney/nixus' at '/home/neoney/nixus'.

and have no useful logs...

Even restarting them manually doesn't bring it back

n3oney commented 7 months ago

Once I did sudo waydroid container stop, restarting the bindMount user services manually worked. Weird thing is, after starting waydroid back up, it didn't remove the mounts that time.

reedrw commented 5 months ago

When this happens, do you see the systemd user units for the mounts? If so, what is their log output?

Applogies for the late reply, the issue resolved itself for some time (and I was not able to reproduce it) but seems to be back now. When this happens, some of the systemd units for the mounts are completely missing and systemctl status --user shows a degraded status. I think this is the same issue as https://github.com/nix-community/home-manager/issues/2252