I don't see any instructions on upgrading nix itself in the manuals, at least not for pre 2.0.
How can I upgrade to 2.0 on mac without uninstalling everything first?
Nix 2.0 is not in Nixpkgs yet, but in the interim you can do nix-env -i /nix/store/xmi4fylvx4qc79ji9v5q3zfy9vfdy4sv-nix-2.0 (probably using sudo if you have a multi-user Nix installation).
@edolstra Ok great, and after doing that are there any shell snippets I need or anything else to do in general?
@edolstra maybe publish the macOS and Linux store paths somewhere canonical for folks wanting to upgrade?
@bryaan you'll probably need to convince launchd to reload the service somehow, if you're on macOS.
@copumpkin system restart enough?
Yes, that should work. Alternatively
sudo launchctl unload /Library/LaunchDaemons/org.nixos.nix-daemon.plist
sudo launchctl load /Library/LaunchDaemons/org.nixos.nix-daemon.plist
@copumpkin The canonical location is https://github.com/NixOS/nixpkgs/raw/master/nixos/modules/installer/tools/nix-fallback-paths.nix. However Nixpkgs master doesn't have 2.0 yet.
Yeah, so I'm just saying maybe it'd be good to put them somewhere else that isn't dependent on the current state of nixpkgs? Otherwise the rest of us either have to wipe and reinstall Nix to get 2.0, or wait for nixpkgs master to catch up.
Yeah, I hunted around for info on how to upgrade, decided to try the installer (i.e. https://nixos.org/nix/install (as per https://nixos.org/nix/download.html).
The installer detected the old version and suggested wiping the old version, including /nix/store a suggestion I now regret following :-(
@vertexcite, why did you regret?
@edolstra, why did that command even work for me? I don't recall building nix 2.0 on my machine.
@ggPeti /nix/store/ was a few GB in size. Not really sure that deleting it was the right thing to do. After installing nix 2.0, starting up a nix shell that was previously working built a few GB in /nix/store/, which took many hours, which I'm guessing would have been there already if I hadn't nuked it. Unless nix 2.0 cannot reuse anything from the previous version of nix?
A user just updated on macOS via:
sudo nix upgrade-nix
sudo launchctl unload /Library/LaunchDaemons/org.nixos.nix-daemon.plist
sudo launchctl load /Library/LaunchDaemons/org.nixos.nix-daemon.plist
and worked for them.
@grahamc be careful with upgrade-nix, it breaks user profiles.
EDIT: See https://github.com/NixOS/nix/issues/2175
@LnL7 Then what is the alternative?
When upgrading from nix-2.0 to nix-2.1.2, I ultimately had to manually track down the new nix-daemon in the store and edit org.nixos.nix-daemon.plist to use it rather than the old version. If that's the intended procedure, it would be nice to print out a message suggesting it somewhere, but I can't think where it could go.
@acowley is this the method you tried first:
" Multi-user Nix users on macOS can upgrade Nix by running: sudo -i sh -c 'nix-channel --update && nix-env -iA nixpkgs.nix && launchctl remove org.nixos.nix-daemon && launchctl load /Library/LaunchDaemons/org.nixos.nix-daemon.plist'
Single-user installations of Nix should run this: nix-channel --update; nix-env -iA nixpkgs.nix "
(Source: https://nixos.org/nix/manual/#ch-upgrading-nix)
@vertexcite Looking at that more carefully, I may have done the channel part incorrectly. I did a sudo -i nix-channel --update, which might not have been enough. I think my channel situation (i.e. who owns what) on that computer is too confusing to be useful, so I should more carefully wipe it out. Thanks for the quote I should have read more carefully.
Awhile ago, I performed a multi-user install of Nix 1.11.16 on Ubuntu 16.04.3. As specified in the INSTALL file for nix-1.11.16, the binaries nix-env, nix-daemon, etc. were installed in /usr/local/bin:
By default,
make installwill install the package's files in/usr/local/bin,/usr/local/man, etc.
When I tried upgrading recently, I checked the docs and ran nix-channel --update && nix-env -iA nixpkgs.nix as root. That updated nix-daemon, etc. for the root user, but it did not update the binaries in /usr/local/bin. So after restarting the nix-daemon service, the nix-daemon was still running version 1.11.16 while the root user was running version 2.x, causing error "unsupported builtin function 'buildenv'" because of the different versions between service and client. I had to manually copy the nix-env, nix-daemon, etc. binaries referenced in /root/.nix-profile/bin over to /usr/local/bin.
Most helpful comment
@LnL7 Then what is the alternative?