Replies: 2 comments 5 replies
|
nope it's not. There are better tools out there to create backups (cp, restic etc) and better ways to deal with that issue. When deploying HM warns you about existing file then you have a choise: either you migrate to a hm module and remove/rename the nagging file or you dont. |
|
Home manager doesn't do backups in a disaster-recovery sense (for which, yes, restic would be an appropriate tool.) Instead, it does something like what Several people (myself included) find this behavior very useful, and it's part of home-manager today. There've been repeated requests for a better UX around its usage, especially when home-manager is a NixOS module. My understanding is that it can be configured to use a backup suffix (a little like Because a) home-manager manipulates many files at once and b) it fails on the first path collision, moving the offending file is a tedious, repetitive task of the sort that I generally expect a machine to do. The basic |
Uh oh!
There was an error while loading. Please reload this page.
For some time, home-manager has been able to move configuration files out of the way as backups (for example, to a path with a
.bakextension added). While this works the first time a managed configuration file replaces an existing file, it has a couple of downsides.First, it litters the filesystem with
.bakfiles that go stale very quickly. They're likely handy for a week or two at most, if the HM replacement doesn't quite do what you wanted. After that, they're just cruft.Second, (and perhaps I'm peculiar in this workflow), one might make a "live" copy of a configuration to test out immediate changes, and then update HM accordingly. The subsequent
home-manager switchwould update the configuration... unless there's already a backup file, in which case it conservatively refuses to clobber the backup.As the original contributor of the backup feature, I've been thinking about these issues on and off for a while now (and seeing frustration in the issues here as backups became part of the NixOS module).
Would it be possible for home-manager to keep a record of the backups it's made? If for example there were a list of paths and digests, maybe in
$XDG_STATE_HOME, then there might be ahome-manager clean-backupsthat goes through the list, deleting any unchanged files. It might also be an optional pre-switch step, which could be enabled by a flag on the command line or an option in the module.My biggest question is: is it appropriate for home-manager to set up such a state file, or is there an existing location that would be better?
@rycee @khaneliman - this feels like a (small) architectural question, so I'd love your input.
All reactions