I’m running a multi-user installation of nix on macOS. Following the instructions here to upgrade nix, I ran into an error on the nix-env -iA nixpkgs.nix step:
error: packages '/nix/store/h1ri3l45xxf42905bw7cgif85qr0445z-home-manager-path/share/zsh/site-functions/_nix' and '/nix/store/gqf7zhkx1n6sijax727ycrm57ikrv3pc-nix-2.15.1/share/zsh/site-functions/_nix' 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)
Why am I getting this error? How can I work around it? This seems like a bug?
As you found out refers to the installed name, not the store path.
The reason this happens is that the package home-manager-path (I assume this is something internal to home manager) installed files into your profile that the package nix also wants to install. Only one package can provide any given path, so this is a conflict that you need to resolve manually.
I guess the reason for this is that you already installed nix via home-manger? Or does home-manager do this by default?
In the former case, you should upgrade nix in your home-manager configuration, not with nix-env directly. In the latter, that does seem like somewhat surprising behaviour.
True, but @samuela didn’t specify whether they were on a single- or multi-user install. I assumed multi-user, and in that case you’d have to upgrade nix with
Installing a new version of nix into your user profile on a multi-user install will also not update the nix daemon, which can lead to some confusing issues.
Hmm yeah and the installation docs for home-manager also assume that nix is already installed, so it shouldn’t install it by default. Maybe something else in your home-manager config depends on nix and installed it? When searching through nixpkgs (crudely), I find 51 packages that depend on nix directly: