-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Optional user defined script for error handling in case of home-manager backup file already existing #6424
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Thank you for your contribution! I marked this issue as stale due to inactivity. Please be considerate of people watching this issue and receiving notifications before commenting 'I have this issue too'. We welcome additional information that will help resolve this issue. Please read the relevant sections below before commenting. If you are the original author of the issue
If you are not the original author of the issue
Memorandum on closing issuesDon't be afraid to manually close an issue, even if it holds valuable information. Closed issues stay in the system for people to search, read, cross-reference, or even reopen – nothing is lost! Closing obsolete issues is an important way to help maintainers focus their time and effort. |
This adds a new backupCommand option to allow users to specify a custom command to run on existing files during activation, as an alternative to the existing backupFileExtension mechanism. Adds backupCommand option to NixOS and nix-darwin modules. Exports HOME_MANAGER_BACKUP_COMMAND environment variable when set. Updates file activation logic to use the custom backup command if provided, falling back to the existing backup extension logic. Updates collision checking and user-facing instructions to mention the new option. This enables advanced backup workflows, such as moving files to trash or archiving with custom tools, before managing them with Home Manager.
This adds a new backupCommand option to allow users to specify a custom command to run on existing files during activation, as an alternative to the existing backupFileExtension mechanism. Adds backupCommand option to NixOS and nix-darwin modules. Exports HOME_MANAGER_BACKUP_COMMAND environment variable when set. Updates file activation logic to use the custom backup command if provided, falling back to the existing backup extension logic. Updates collision checking and user-facing instructions to mention the new option. This enables advanced backup workflows, such as moving files to trash or archiving with custom tools, before managing them with Home Manager.
I have created a pull request for this. I've been using this branch for 3 weeks setting |
Description
There have been several proposals for handling failures for backup of files stopping the home-manager activation, because there is a need in special cases which can not be solved with e.g. forcing overwrite for a single specified file. Unfortunately it seems that there is no consensus how to deal with that error case: setting a global force-overwrite flag was considered too risky because something important could be deleted (by intended or even unintended behaviour).
My proposal is to give that decision to a user defined optional error handling script with an option like home-manager.backupFileExistsHook. This bash script should be executed in case of "backup file already exists" and two environment variables (e.g. ORIGINALFILE, BACKUPFILE) should be set. Then the user can define any strategy wanted (from renaming the backups with dates in the filname to moving with overwriting). If the script returns no error and made space for writing a new file in the place of "ORIGINALFILE" the home-manager activation can continue. If no script is set at all, same backward compatible behaviour of immediate failure.
The text was updated successfully, but these errors were encountered: