Skip to content
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

Optional user defined script for error handling in case of home-manager backup file already existing #6424

Open
Doc-Steve opened this issue Feb 9, 2025 · 0 comments
Assignees

Comments

@Doc-Steve
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants