I have a system on which Nix was installed using
apt install nix-bin. I am attempting to reinstall Nix using the official install script (
sh <(curl -L https://nixos.org/nix/install) --daemon). I removed Nix using
apt remove nix*, but when I run the install script I get an error:
error: profile ‘/nix/var/nix/profiles/default’ is incompatible with ‘nix-env’; please use ‘nix profile’ instead.
I understand why this is happening - I believe it is occurring on line 924 of install-multi-user of the scripts downloaded by the original install script. We have installed packages on the original Nix installation using
nix profile, but the official install script is running
nix-env in order to configure the whole environment. Because we have run
nix profile and are now trying to run
nix-env, we are running into an incompatibility.
I also understand that I can fix this by removing the current profile directory. However, as I understand it, that will effectively uninstall my current packages.
Is there a way to reinstall Nix without having to reinstall my packages? I may be understanding Nix incorrectly and there is a way to restore my profile without reinstalling packages. I’d hope that Nix allows for a reinstall without starting over.
System: Ubuntu 22.04
Nix version: 2.16.1
It should be noted that I am using version 2.16.1, rather than 2.17.x that came out this week.