Way to automatically override home manager collisions?

I use home manager as a nixos module and have multiple users. Home manager controls the configuration for some files in the users home directories, which causes collisions. To prevent home manager from terminating, I created an alias that deletes the files that home manager generates before rebuilding.

EX:
sudo rm -rf /home/user1/.config/mimeapps.list &&
sudo rm -rf /home/user1/.local/share/applications/mimeapps.list &&
sudo rm -rf /home/user1/.mozilla/firefox/profiles.ini &&
sudo rm -rf /home/user2/.config/mimeapps.list &&
sudo rm -rf /home/user2/.local/share/applications/mimeapps.list &&
sudo rm -rf /home/user2/.mozilla/firefox/profiles.ini &&
sudo nixos-rebuild switch

The problem with this is that sometimes I’ll have a change to a single users configuration. Home manager will change and overwrite the config files for the user with changes, but not the one without changes. So my alias will delete the config for the un-changed user and they won’t be regenerated. The only way I found to fix this is to make a new change to both users and run my rebuild again.

Is a better way to handle this? Can’t find any information on how to just make home manager ignore collisions. Or maybe I can make my bash alias smarter by detecting changes before deleting?

1 Like

Assuming you’re using the NixOS module, you probably want to use home-manager.backupFileExtension instead of deleting anything. Otherwise use the -b switch for the same effect with the home-manager CLI.

4 Likes

There is a .force which is not shown in the documentation

xdg.configFile."mimeapps.list".force = true;

2 Likes

Assuming you’re using the NixOS module, you probably want to use home-manager.backupFileExtension instead of deleting anything. Otherwise use the -b switch for the same effect with the home-manager CLI.

The link is dead, this is the source for that option: https://github.com/nix-community/home-manager/blob/8c3b2a0cab64a464de9e41a470eecf1318ccff57/nixos/common.nix#L55

Odd, seems it has a .xhtml extension now. I updated the link.

Oh, cool. I was always looking only into Appendix A and I haven’t found it there. That’s why I pasted the source.

Thanks for the info that nixos-specific stuff is in Appendix B.