# Flake + Homemanager backup

**URL:** https://discourse.nixos.org/t/flake-homemanager-backup/49043
**Category:** Help
**Created:** [July 14, 2024, 9:05am UTC](https://discourse.nixos.org/t/flake-homemanager-backup/49043 "2024-07-14T09:05:15Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![Rabid3east](https://discourse.nixos.org/user_avatar/discourse.nixos.org/rabid3east/32/7316_2.png) [@Rabid3east](https://discourse.nixos.org/u/Rabid3east)
#### Post date: [July 14, 2024, 9:05am UTC](https://discourse.nixos.org/t/flake-homemanager-backup/49043/1 "2024-07-14T09:05:16Z")

</div>

I used to have my system working but started getting an error with a package from an unstable file so updating my system to 24.05 on all my packages. But in the process my system is unable to build because something is conflicting. I am unable to get home-manager to backup with the setting that was suggest nor the command line. My flake and home-manager build as one.

Here is my error code:

```auto
justin@nixos:~/.dots/modules/wm/hyprland/ > rebuild-desktop
warning: Git tree '/home/justin/.dots' is dirty
building the system configuration...
warning: Git tree '/home/justin/.dots' is dirty
trace: warning: justin profile: The option `programs.zsh.enableAutosuggestions' defined in `/nix/store/0hby9z8dhpi1pqidnwhjhxbn69gyc1cm-source/home/justin.nix' has been renamed to `programs.zsh.autosuggestion.enable'.
trace: warning: The option `services.avahi.nssmdns' defined in `/nix/store/0hby9z8dhpi1pqidnwhjhxbn69gyc1cm-source/hosts/nixos/seykota/default.nix' has been renamed to `services.avahi.nssmdns4'.
activating the configuration...
setting up /etc...
reloading user units for justin...
restarting sysinit-reactivation.target
warning: the following units failed: home-manager-justin.service

× home-manager-justin.service - Home Manager environment for justin
     Loaded: loaded (/etc/systemd/system/home-manager-justin.service; enabled; preset: enabled)
     Active: failed (Result: exit-code) since Sun 2024-07-14 09:02:31 UTC; 79ms ago
   Duration: 20min 33.982s
    Process: 4043753 ExecStart=/nix/store/6mhjswwdl1b6msyiml5bxmdqrhhi6x36-hm-setup-env /nix/store/zqn2n7n9vnvq9ggfd66zg4i18bga821f-home-manager-generation (code=exited, status=1/FAILURE)
   Main PID: 4043753 (code=exited, status=1/FAILURE)
         IP: 0B in, 0B out
        CPU: 78ms

Jul 14 09:02:31 nixos hm-activate-justin[4043831]: Please do one of the following:
Jul 14 09:02:31 nixos hm-activate-justin[4043831]: - Move or remove the above files and try again.
Jul 14 09:02:31 nixos hm-activate-justin[4043831]: - In standalone mode, use 'home-manager switch -b backup' to back up
Jul 14 09:02:31 nixos hm-activate-justin[4043831]: files automatically.
Jul 14 09:02:31 nixos hm-activate-justin[4043831]: - When used as a NixOS or nix-darwin module, set
Jul 14 09:02:31 nixos hm-activate-justin[4043831]: 'home-manager.backupFileExtension'
Jul 14 09:02:31 nixos hm-activate-justin[4043831]: to, for example, 'backup' and rebuild.
Jul 14 09:02:31 nixos systemd[1]: home-manager-justin.service: Main process exited, code=exited, status=1/FAILURE
Jul 14 09:02:31 nixos systemd[1]: home-manager-justin.service: Failed with result 'exit-code'.
Jul 14 09:02:31 nixos systemd[1]: Failed to start Home Manager environment for justin.
warning: error(s) occurred while switching to the new configuration

```

---

<div class="post-metadata">

### Author: ![julmx](https://discourse.nixos.org/letter_avatar_proxy/v4/letter/j/eada6e/32.png) [@julmx](https://discourse.nixos.org/u/julmx)
#### Post date: [July 14, 2024, 9:48am UTC](https://discourse.nixos.org/t/flake-homemanager-backup/49043/2 "2024-07-14T09:48:55Z")

</div>

Hi, i have a similar issue. The error message suggest to move or remove a file, but i don’t know wich file is causing the conflict.

```auto
× home-manager-julmx.service - Home Manager environment for julmx
     Loaded: loaded (/etc/systemd/system/home-manager-julmx.service; enabled; preset: enabled)
     Active: failed (Result: exit-code) since Sun 2024-07-14 11:26:16 CEST; 75ms ago
   Duration: 23h 36min 31.246s
    Process: 2081057 ExecStart=/nix/store/6mhjswwdl1b6msyiml5bxmdqrhhi6x36-hm-setup-env /nix/store/z6lhz8hp2w66rvkpxlk7q9w4wd52wzr7-home-manager-generation (code=exited, status=1/FAILURE)
   Main PID: 2081057 (code=exited, status=1/FAILURE)
         IP: 0B in, 0B out
        CPU: 136ms

juil. 14 11:26:16 mainPC hm-activate-julmx[2081154]: Please do one of the following:
juil. 14 11:26:16 mainPC hm-activate-julmx[2081154]: - Move or remove the above files and try again.
juil. 14 11:26:16 mainPC hm-activate-julmx[2081154]: - In standalone mode, use 'home-manager switch -b backup' to back up
juil. 14 11:26:16 mainPC hm-activate-julmx[2081154]: files automatically.
juil. 14 11:26:16 mainPC hm-activate-julmx[2081154]: - When used as a NixOS or nix-darwin module, set
juil. 14 11:26:16 mainPC hm-activate-julmx[2081154]: 'home-manager.backupFileExtension'
juil. 14 11:26:16 mainPC hm-activate-julmx[2081154]: to, for example, 'backup' and rebuild.
juil. 14 11:26:16 mainPC systemd[1]: home-manager-julmx.service: Main process exited, code=exited, status=1/FAILURE
juil. 14 11:26:16 mainPC systemd[1]: home-manager-julmx.service: Failed with result 'exit-code'.
juil. 14 11:26:16 mainPC systemd[1]: Failed to start Home Manager environment for julmx.
warning: error(s) occurred while switching to the new configuration

```

---

<div class="post-metadata">

### Author: ![TLATER](https://discourse.nixos.org/user_avatar/discourse.nixos.org/tlater/32/4257_2.png) [@TLATER](https://discourse.nixos.org/u/TLATER)
#### Post date: [July 14, 2024, 10:34am UTC](https://discourse.nixos.org/t/flake-homemanager-backup/49043/3 "2024-07-14T10:34:15Z")

</div>

Looks like the important part of the journal is being cut off. You’ll need to read the full log of the service.

@Rabid3east try:

```auto
journalctl -e --user --unit home-manager-justin.service

```

@julmx try:

```auto
journalctl -e --user --unit home-manager-julmx.service 

```

The CLI option cannot apply to the NixOS module (and you should get an explicit error, not getting one isn’t a good sign?), though the option should work.

Going on a tangent here, but that means you _have_ updated, there’s just one config file that isn’t being applied during the activation script. This only happens with home-manager, when some random application overwrites its symlinks. IME this usually happens with the mime config files, since wine applications don’t handle symlinks well.

---

<div class="post-metadata">

### Author: ![julmx](https://discourse.nixos.org/letter_avatar_proxy/v4/letter/j/eada6e/32.png) [@julmx](https://discourse.nixos.org/u/julmx)
#### Post date: [July 14, 2024, 11:43am UTC](https://discourse.nixos.org/t/flake-homemanager-backup/49043/4 "2024-07-14T11:43:13Z")

</div>

got it to rebuild using :

```auto
home-manager.backupFileExtension = "bkp";

```

then, i get the same issue again.  
Apparently, the .bkp files create a conflict too, so i used

```auto
find . -name '*.bkp'

```

to find and remove the \*.bkp files created. I suppose there is a better way to do it.

Maybe our issue is related to this :

> <https://github.com/nix-community/home-manager/issues/4199>
>
> Having Home Manager fail if an existing file exists is a big foot-gun. As a vete…ran user, I know what it means when the Home Manager service fails. I know to delete the offending file and reactive the service.
> 
> However, I have seen new users struggle with broken configurations, unsure why their Home Manager changes are not realized. Worse, this allows NixOS to update with Home Manager, potentially breaking systems. Worse still, if an existing file exists, users cannot cleanly roll back to previous NixOS generations because Home Manager will fail to realize those previous generations. In the worst case, this can result in an unusable machine with no way to roll back, requiring recovery from a bootable USB.
> 
> P.S. This is not a one-off issue. Some applications will override files managed by Home Manager, resulting in this error cropping up repeatedly, even if \`backupFileExtension\` is set.

```auto
journalctl -e --user --unit home-manager-julmx.service 

```

return “No entrie”, maybe because i successfully rebuild my conf ?

---

<div class="post-metadata">

### Author: ![TLATER](https://discourse.nixos.org/user_avatar/discourse.nixos.org/tlater/32/4257_2.png) [@TLATER](https://discourse.nixos.org/u/TLATER)
#### Post date: [July 14, 2024, 1:40pm UTC](https://discourse.nixos.org/t/flake-homemanager-backup/49043/5 "2024-07-14T13:40:03Z")

</div>

> [@julmx](#):
>
> No entrie

Oh, whoops, sorry, it’s not a user service. Drop the `--user` and it should give you logs.

You could also just check which file was backed up, just need to figure out what application is overwriting your symlink and why.

---

<div class="post-metadata">

### Author: ![julmx](https://discourse.nixos.org/letter_avatar_proxy/v4/letter/j/eada6e/32.png) [@julmx](https://discourse.nixos.org/u/julmx)
#### Post date: [July 14, 2024, 1:52pm UTC](https://discourse.nixos.org/t/flake-homemanager-backup/49043/6 "2024-07-14T13:52:50Z")

</div>

thanks, i see which file is causing the conflict :

```auto
juil. 14 15:49:44 mainPC hm-activate-julmx[2489178]: Existing file '/home/julmx/.config/mimeapps.list.bkp' would be clobbered by backing up '/home/julmx/.config/mimeapps.list'

```

---

<div class="post-metadata">

### Author: ![TLATER](https://discourse.nixos.org/user_avatar/discourse.nixos.org/tlater/32/4257_2.png) [@TLATER](https://discourse.nixos.org/u/TLATER)
#### Post date: [July 14, 2024, 2:01pm UTC](https://discourse.nixos.org/t/flake-homemanager-backup/49043/7 "2024-07-14T14:01:22Z")

</div>

Yeah, as expected. IME this is when you start wine applications that register a new mime type on startup. I believe wine doesn’t support symlinks and turns them into normal files whenever that happens.

Best way to fix that is to look at what mime handlers get randomly registered and writing them to the list yourself.

It doesn’t cause the deployment to fail, anyway, this is more of a warning.

---

<div class="post-metadata">

### Author: ![Rabid3east](https://discourse.nixos.org/user_avatar/discourse.nixos.org/rabid3east/32/7316_2.png) [@Rabid3east](https://discourse.nixos.org/u/Rabid3east)
#### Post date: [July 14, 2024, 2:22pm UTC](https://discourse.nixos.org/t/flake-homemanager-backup/49043/8 "2024-07-14T14:22:56Z")

</div>

After removing --user to the command i was able to narrow down the conflicting file from alacritty and remove it. Everything is working as intended, thank you!
