Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade Nix #596

Closed
mig4ng opened this issue Aug 2, 2023 · 8 comments
Closed

Upgrade Nix #596

mig4ng opened this issue Aug 2, 2023 · 8 comments

Comments

@mig4ng
Copy link
Contributor

mig4ng commented Aug 2, 2023

Hello, I have a some of questions:

  1. Is there any specific reason not to update Nix to 2.17?
  2. What is the recommended way to upgrade Nix? Following https://nixos.org/manual/nix/stable/installation/upgrading.html or using nix upgrade-nix?
  3. Is it okay to run nix upgrade-nix as sudo on MacOS? It shows error: opening lock file '/nix/var/nix/profiles/default.lock': Permission denied without it.
  4. Why does sudo nix upgrade-nix only updates to 2.15.1 instead of 2.17.0?

It would be nice to have a section on updating Nix with the DeterminateSystems installer. I can open a PR with it, it appears to be something like this:


Upgrade/Update Nix

Run the upgrade command:

nix upgrade-nix

Or, uninstall and run the installer again.


          Generally to upgrade Nix you should use `nix upgrade-nix` or uninstall (`/nix/nix-installer uninstall`) and reinstall.

Originally posted by @Hoverbear in #595 (comment)

@Hoverbear
Copy link
Contributor

Hoverbear commented Aug 2, 2023

Hi! Generally nix upgrade-nix is how we suggest things. Yes this requires sudo on Mac!

nix upgrade-nix checks what the nix project has set in https://raw.githubusercontent.com/NixOS/nixpkgs/master/nixos/modules/installer/tools/nix-fallback-paths.nix to determine the version to use.

A PR to add the section you suggest would be welcome! It would fit best right below usage and above uninstalling.

@mig4ng
Copy link
Contributor Author

mig4ng commented Aug 4, 2023

Created PR, closing this.

@mig4ng mig4ng closed this as completed Aug 4, 2023
@bestlem
Copy link

bestlem commented Aug 6, 2023

From your install etc on macos I get

sudo nix -vvvv upgrade-nix
Password:
warning: $HOME ('/Users/dev') is not owned by you, falling back to the one defined in the 'passwd' file ('/var/root')
found Nix in '/nix/store/gqf7zhkx1n6sijax727ycrm57ikrv3pc-nix-2.15.1/bin'
found profile '/nix/store/gqf7zhkx1n6sijax727ycrm57ikrv3pc-nix-2.15.1'
error: directory '/nix/store/gqf7zhkx1n6sijax727ycrm57ikrv3pc-nix-2.15.1/bin' does not appear to be part of a Nix profile

Uninstall failed as

   0: Error reverting
   0: Action `create_apfs_volume` errored
      Failed to execute command with status 1 `"/usr/sbin/diskutil" "apfs" "deleteVolume" "Nix Store"`, stdout: Started APFS operation
      Deleting APFS Volume from its APFS Container
      Unmounting disk3s7
      The volume "Nix Store" on disk3s7 couldn't be unmounted because it is in use by process 0 (kernel)

      stderr: Error: -69888: Couldn't unmount disk

OK I had a terminal open using a shell on nix so tried again and got a very long error message.

@mig4ng
Copy link
Contributor Author

mig4ng commented Aug 8, 2023

@bestlem I am not sure what is causing your error. But since you have a long error message when you tried again, share that one here as well, it might help.

I noticed after installing nix-darwin again via flakes (this experimental guide), that I am having the following error trying to upgrade:

$ sudo nix upgrade-nix
warning: $HOME ('/Users/mig') is not owned by you, falling back to the one defined in the 'passwd' file ('/var/root')
error: Nix on NixOS must be upgraded via 'nixos-rebuild'

I will reopen the issue, however, these errors seem to be unrelated to the nix-installer, so feel free to close it again.
I am keeping it open because I really like the nix-installer and it would be nice to understand what is happening and if it is at all compatible with nix-darwin or if we should avoid having both.

Edit: darwin-rebuild switch --flake ~/.config/nix-darwin (not nixos-rebuild) works to rebuild the configuration/system, but I am not sure how to upgrade the Nix version with this (or if it upgrades automatically to the pinned version e.g. #598 (comment)).

@mig4ng mig4ng reopened this Aug 9, 2023
@bestlem
Copy link

bestlem commented Aug 9, 2023

Unfortunately the error was too long for github - and I have now lost it.

The issue seems to be how do you update nix and I am following your instructions.

@bestlem
Copy link

bestlem commented Aug 11, 2023

This time on a clean virtual machine sudo nix upgrade-nix change nix version from 2.15.0 to 2.15.1 with the warning that the home directory is incorrect - which I think is a sudo warning so nothing to do with nix.

The questionI have now is how do I upgrade to the latest nix which I think is 2.17?

@Hoverbear
Copy link
Contributor

I believe you may have been affected by some of the issues around the nix profile location changes of that version. If you have already used nix-installer, it's probably safest to run /nix/nix-installer uninstall then remove any ~/.nix* files you might see. Reinstalling using the latest (0.11.0) version should yield Nix 2.17.

@Hoverbear
Copy link
Contributor

@mig4ng documented this process so I believe this ticket is closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants