Home-manager -b <ext> switch failure

I really love home-manager’s

home.file.<target>.source = <source>

feature [though I have recently started using a more flexible variation on the theme

{ config, pkgs, ... }:
  link = config.lib.file.mkOutOfStoreSymlink;
in
{
  home.file.<target>.source = link <source>;
}

but that’s not directly relevant here].

If the target already exists (and wasn’t put there by home-manager in the first place) home-manager switch fails with the very reasonable error message

Existing file '/home/whoever/target' is in the way of '/nix/store/x0jc9dfic44p8kxm1vmdm1d0wclx1pc6-home-manager-files/target'
Please move the above files and try again or use -b <ext> to move automatically.

man home-manager has this to say about -b:

  -b extension
           Enable automatic resolution of collisions between unmanaged and managed files. The name of the original file will be suffixed by the given extension. For example,

               $ home-manager -b bck switch

           will cause a colliding file ~/.config/foo.conf to be moved to ~/.config/foo.conf.bck.

As man pages go, this is unusually lucid.

All good stuff! So what’s the problem? Well, executing

home-manager -b bck switch

gives exactly the same error as before.

I’ve been staring at this for a while and two possible explanations come to mind:

  1. I’m missing something bloody obvious
  2. home-manager -b is broken

Any ideas?

1 Like

My guess is that ~/.config/foo.conf is a symlink. Unfortunately these are currently not handled by the code that does the moving. I don’t think it would be particularly hard to fix, just haven’t been a concern before :slightly_smiling_face: