1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-11-08 11:36:05 +01:00

home-manager: add support for custom backup command (#6424) (#7153)

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 commit is contained in:
Christina O'Donnell 2025-10-30 17:26:13 +00:00 committed by GitHub
parent c6d4cb31d7
commit ce76393bb7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 40 additions and 11 deletions

View file

@ -81,6 +81,16 @@ in
argument in Home Manager. This disables the Home Manager
options {option}`nixpkgs.*`'';
backupCommand = mkOption {
type = types.nullOr (types.either types.str types.path);
default = null;
example = lib.literalExpression "''${pkgs.trash-cli}/bin/trash";
description = ''
On activation run this command on each existing file
rather than exiting with an error.
'';
};
backupFileExtension = mkOption {
type = types.nullOr types.str;
default = null;