NixOS rebuild fails on backup up config file by home-manager

Hi!

I’m using NixOS (24.05, unstable) with Home Manager to configure my Firefox. It often happened that nixos-rebuild switch failed because Home Manager wanted to override an existing config file (/home/rob/.mozilla/firefox/rob/search.json.mozlz4). So I activated the Home Manager option home-manager.backupFileExtension = "backup", which would backup the file with an extension instead of just overwriting it. But now the NixOS rebuild fails again, but with the backed up file:

Existing file '/home/rob/.mozilla/firefox/rob/search.json.mozlz4.backup' would be clobbered by backing up '/home/rob/.mozilla/firefox/rob/search.json.mozlz4'

What am I missing? Is there an option to tell Home Manager to just overwrite the backed up file?

Thanks for your help!

Rob

Hi,

I also have some home activation issues while I’m using backFileExtension, there is an issue open.

I recently tried to use a timestamp in backupFileExtension as a workaround, but the timestamp is not refreshed on home activation (got the timestamp trick here, but I failed to use builtins.currentTime):

# one try
home-manager.backupFileExtension = "backup-" + pkgs.lib.readFile "${pkgs.runCommand "timestamp" {} "echo -n `date '+%Y%m%d%H%M%S'` > $out"}";

# another one
home-manager.backupFileExtension = "backup-" + pkgs.lib.readFile "${pkgs.runCommand "timestamp" { env.when = self.sourceInfo.lastModified; } "echo -n `date '+%Y%m%d%H%M%S'` > $out"}";

Maybe someone has an idea on how to get a new timestamp on every activation, it should work then :slight_smile:

1 Like