How to update nixpkgs?

I was installing home-manager and I received this warning:

trace: **warning: You are using**

**Home Manager version 24.05 and**

**Nixpkgs version 23.11.**

**Using mismatched versions is likely to cause errors and unexpected**

**behavior. It is therefore highly recommended to use a release of Home**

**Manager that corresponds with your chosen release of Nixpkgs.**

**If you insist then you can disable this warning by adding**

**home.enableNixpkgsReleaseCheck = false;**

**to your configuration.**

How can I install the version 24.05 of the nixpkgs? I am using MacOS

It depends.

  • flakes: update the input
  • Channels: update the nixpkgs channel

In either case I assume you are already on unstable.


Most likely this means nix-channel --update (updates all channels), since not knowing how likely means you’ve also not learned about flakes or niv or anything.

If not, switch to unstable first:

nix-channel --add nixpkgs

After I updated nix using sudo -i sh -c 'nix-channel --update && nix-env --install --attr nixpkgs.nix && launchctl remove org.nixos.nix-daemon && launchctl load /Library/LaunchDaemons/org.nixos.nix-daemon.plist' I updated my nixpkgs to version 24.05:

 nix-instantiate --eval -E '(import <nixpkgs> {}).lib.version'       

but my home-manager now have the version 23.11-pre:

home-manager --version

I am using unstable:

sh-3.2# nix-channel --list



What are your root users’ channels?

sudo nix-channel --list

Your user/root can have different channels, presumably you’re using those, and have home-manager set to a weird channel.

1 Like

These are my root users’ channels:

joao@Joaos-MacBook-Pro ~ % sudo nix-channel --list
**warning:** $HOME ('/Users/joao') is not owned by you, falling back to the one defined in the 'passwd' file ('/var/root')

Ah, right, that’s the home-manager version, not the channel version. How did you install it, with nix-env?

Either way you need to also add the correct home-manager channel, as the manual says:

1 Like

I installed nix following Install Nix — documentation curl -L | sh

I installed home-manager in this way:

$ nix-channel --add home-manager
$ nix-channel --update
$ nix-shell '<home-manager>' -A install

I noticed now that the Home Manager Manual says:

  1. Make sure you have a working Nix installation. Specifically, make sure that your user is able to build and install Nix packages. For example, you should be able to successfully run a command like nix-instantiate '<nixpkgs>' -A hello without having to switch to the root user. For a multi-user install of Nix this means that your user must be covered by the allowed-users Nix option. On NixOS you can control this option using the nix.settings.allowed-users system option.

and I verified now that I can not successfully run nix-instantiate '<nixpkgs>' -A hello in my normal user:

joao@Joaos-MacBook-Pro ~ % nix-instantiate '<nixpkgs>' -A hello
       … while evaluating a branch condition

         at /nix/store/81d6lv96pws78iijmmsra5ql8wxgb1cb-nixpkgs/nixpkgs/pkgs/stdenv/booter.nix:99:7:

           98|     thisStage =
           99|       if args.__raw or false
             |       ^
          100|       then args'

       … in the right operand of the update (//) operator

         at /nix/store/81d6lv96pws78iijmmsra5ql8wxgb1cb-nixpkgs/nixpkgs/pkgs/stdenv/booter.nix:84:7:

           83|       { allowCustomOverrides = index == 1; }
           84|       // (stageFun prevStage))
             |       ^
           85|     (lib.lists.reverseList stageFuns);

       (stack trace truncated; use '--show-trace' to show the full trace)

       error: cannot connect to socket at '/nix/var/nix/daemon-socket/socket': Connection refused

But I don’t think this is the reason for the version problem. Following the manual I should install other version of home-manager, for now I will uninstall the home-manager and later I will install the home-manager following the nixpkgs version.

In this case the correct is to install home-manager following nixpkgs version or can I update nixpkgs to follow the home-manager version?

After a reboot the command works:

joao@Joaos-MacBook-Pro ~ % nix-instantiate '<nixpkgs>' -A hello
warning: you did not specify '--add-root'; the result might be removed by the garbage collector

Reference: nix 2.0 on macOS High Sierra - error: cannot connect to daemon at '/nix/var/nix/daemon-socket/socket' · Issue #1980 · NixOS/nix · GitHub

I removed home-manager:

home-manager uninstall
nix-channel --remove home-manager

And installed it again the master version because I am using unstable nixpkgs and it works even though I am not using the exactly same version of home-manager and Nixpkgs I did not received the warning :slight_smile:
Thank you @TLATER and @NobbZ

1 Like