Home-manager conflict after nix upgrade

Hi all,

I really don’t know where to ask this question so I am trying here.
I am on macOS darwin, and I use home-manager.

I recently wanted to upgrade to the latest nix (2.5.1) but by doing so calling home-manager sync or even trying to re-install home-manager via nix-shell '<home-manager>' -A install fails with this error:

building '/nix/store/rc1l9h28xrgfymjl3zsja24wnlwayv2s-user-environment.drv'...
error: packages '/nix/store/fq0v0m7lhqrc2j7x1b5d7bw8jyi083lj-nix-2.5.1/bin/nix-prefetch-url' and '/nix/store/93qibvqxgqii6nxqz8kfdk6q11gsbaak-home-manager-path/bin/nix-prefetch-url' have the same priority 5; use 'nix-env --set-flag priority NUMBER INSTALLED_PKGNAME' to change the priority of one of the conflicting packages (0 being the highest priority)
error: builder for '/nix/store/rc1l9h28xrgfymjl3zsja24wnlwayv2s-user-environment.drv' failed with exit code 1

So I have 3 computer I would like to upgrade. For one of them, I’ve fixed this issue by completely deleting and reinstalling nix (and of course the /nix).
So I would like to better understand what is going on here, and if there is a way to fix this issue without wiping out nix entirely.

I have tried:

  1. changing the priority (I think I am not doing it correctly)
  2. trying to uninstall home-manager via nix-env -e home-manager-path.
  3. nix-garbage-collect -d
  4. manually rm the conflicting files (it makes the issue going further and further, but ultimately I end up with a major issue)
  5. using an empty home.nix works as expected. I think there might be a single package creating this issue. But the message does not make it clear which one.


> nix-env -q

So now I am just asking for help, can I fix the issue without removing my entire /nix?


While writing this question I found the solution, the conflicting package was nix, even if it was not explicitly put in my home.nix config.

nix-env -e home-manager-path
nix-env --set-flag priority 4 nix
nix-shell '<home-manager>' -A install

@yogsototh did you happen to have both nix and cacert in your home.packages list?

If so the alternative would be nix-env -e nix nss-cacert and then re-switching home manager.

nix-env --set-flag priority 4 home-manager-path does the trick also it seems