Nixos-rebuild fails due to home-manager

My nixos-rebuild fails because it cannot restart home-manager-klt.service.
The error help suggest to Move or remove the above files and try again.
However I do not see any file names.

Here the output

➜ sudo nix-channel --list

home-manager https://github.com/nix-community/home-manager/archive/release-25.05.tar.gz
nixos https://nixos.org/channels/nixos-25.05
➜ sudo nixos-rebuild switch

building Nix...
building the system configuration...
evaluation warning: substituteAll is deprecated and will be removed in 25.11. Use replaceVars instead.
activating the configuration...
setting up /etc...
reloading user units for klt...
restarting sysinit-reactivation.target
the following new units were started: NetworkManager-dispatcher.service
warning: the following units failed: home-manager-klt.service
× home-manager-klt.service - Home Manager environment for klt
     Loaded: loaded (/etc/systemd/system/home-manager-klt.service; enabled; preset: ignored)
     Active: failed (Result: exit-code) since Fri 2025-08-01 08:26:41 CEST; 472ms ago
 Invocation: 4811641be7e446ad99db7607b638d9fe
    Process: 11447 ExecStart=/nix/store/d6mhq77jyaidz98k11wj0xragdkmw1a0-hm-setup-env /nix/store/f4qkz7fa17xcm4lvlx92yvd89j1cln9y-home-manager-generation (code=exited, status=1/FAILURE)
   Main PID: 11447 (code=exited, status=1/FAILURE)
         IP: 0B in, 0B out
         IO: 0B read, 0B written
   Mem peak: 6M
        CPU: 129ms

Aug 01 08:26:41 maxiTower hm-activate-klt[11629]: Please do one of the following:
Aug 01 08:26:41 maxiTower hm-activate-klt[11629]: - Move or remove the above files and try again.
Aug 01 08:26:41 maxiTower hm-activate-klt[11629]: - In standalone mode, use 'home-manager switch -b backup' to back up
Aug 01 08:26:41 maxiTower hm-activate-klt[11629]:   files automatically.
Aug 01 08:26:41 maxiTower hm-activate-klt[11629]: - When used as a NixOS or nix-darwin module, set
Aug 01 08:26:41 maxiTower hm-activate-klt[11629]:     'home-manager.backupFileExtension'
Aug 01 08:26:41 maxiTower hm-activate-klt[11629]:   to, for example, 'backup' and rebuild.
Aug 01 08:26:41 maxiTower systemd[1]: home-manager-klt.service: Main process exited, code=exited, status=1/FAILURE
Aug 01 08:26:41 maxiTower systemd[1]: home-manager-klt.service: Failed with result 'exit-code'.
Aug 01 08:26:41 maxiTower systemd[1]: Failed to start Home Manager environment for klt.
warning: error(s) occurred while switching to the new configuration

Has anyone an idea what to do?

I import home-manager into my configuration.nix:

  imports = [
    # Include the results of the hardware scan.
    ./hardware-configuration.nix

...

    # Include Home Manager Config
    ./home.nix
    # Update PostGre
    # ./postgresUpdateScript.nix
  ] ++ prop.specificImports;

Systemd doesn’t show enough of the log by default to see the file names. Check systemctl status -n100 home-manager-klt.service to see (probably) the full log.

Or allow home-manger to create a backup file, then the error will not occur again in the future!

home-manager.backupFileExtension = "hm.OLD"; # Automatic backup of conflicting configuration files.

I believe it still fails if the backup file already exists in that case, so it’s not all that useful, as you still need to do something manually to avoid problems.

It’s not true, you will have to manually delete the existing backup then once the config is updated and rebuilt the backup files work. Had this happen to me and I just added the line like @DocBrown101 show’d and it worked.

Edit: my bad, misread your comment, you’re right manual intervention is required as you said. Sorry.

My mistake:
I have installed software from MicroSoft:

➜  ~ systemctl status -n100 home-manager-klt.service
...
Aug 10 13:13:42 maxiTower hm-activate-klt[100536]: Existing file '/home/klt/.config/teams-for-linux/Preferences.backup' would be clobbered by backing up '/home/klt/.config/teams-for-linux/Preferences'

but I need Teams for my work :rage:

I do not like to back up automatically, because there might be cases when I want to keep the original file. Moreover would I see which config files have been back upped?

Nevertheless, the command systemctl status home-manager-klt.service should not say Move or remove the above files and try again without showing any files. I understand that there are different levels of verbosity but each should be consistent.

A PR improving this has recently been merged, though not yet backported to HM 25.05.

HM does not intentionally truncate this output or hide the files behind any sort of a verbosity level It is simply an effect of it shelling out to systemctl status which by default only lists a small amount of log output for the unit.

1 Like