mirror of
https://github.com/nix-community/home-manager.git
synced 2026-01-12 01:59:37 +08:00
home-manager: add backup overwrite option
When using the backupFileExtension option, if the backup file exists, the activation process fails. This adds an option to instead overwrite the old backup instead of failing.
This commit is contained in:
committed by
Austin Horstman
parent
7500458e85
commit
004753ae6b
@@ -33,8 +33,10 @@ for sourcePath in "$@" ; do
|
||||
elif [[ ! -L "$targetPath" && -n "$HOME_MANAGER_BACKUP_EXT" ]] ; then
|
||||
# Next, try to move the file to a backup location if configured and possible
|
||||
backup="$targetPath.$HOME_MANAGER_BACKUP_EXT"
|
||||
if [[ -e "$backup" ]]; then
|
||||
if [[ -e "$backup" && -z "$HOME_MANAGER_BACKUP_OVERWRITE" ]] ; then
|
||||
collisionErrors+=("Existing file '$backup' would be clobbered by backing up '$targetPath'")
|
||||
elif [[ -e "$backup" && -n "$HOME_MANAGER_BACKUP_OVERWRITE" ]] ; then
|
||||
warnEcho "Existing file '$targetPath' is in the way of '$sourcePath' and '$backup' exists. Backup will be clobbered due to HOME_MANAGER_BACKUP_OVERWRITE=1"
|
||||
else
|
||||
warnEcho "Existing file '$targetPath' is in the way of '$sourcePath', will be moved to '$backup'"
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user