How should I be updating my nixpkgs on macos?

To avoid an XY problem… I’m trying to do this so that I can install a recently published MELPA package in my emacsWithPackages inside home-manager. If there’s a better way to do this, I’m happy to hear it. :slight_smile: Now, on with the show.

I see in nix-channel --help that we’re supposed to:

  1. nix-channel --update to get new updates
  2. now we can verify which version we’re on with nix-instantiate --eval -E '(import <nixpkgs> {}).lib.nixpkgsVersion' (or, since you get a warning, .lib.version.)

This seems reasonable! But when I try it, I perpetually get the same version. Namely, 18.09pre151052.4477cf04b67 when I see that the latest nixpkgs-unstable is 19.03pre152857.947ae71dcec.

Now, curiously, if I run nix-channel --update --verbose, I can see that the actual latest URL is being downloaded, but the nix-instantiate call still returns the old version, and so do other things which import <nixpkgs>.

Any ideas what’s going on here?

Bonus question, and I think this may be core to what’s happening here, how is <nixpkgs> resolved in an expression? My searching is not turning up a lot about how that particular form of import works.

Software Version
Nix 2.1.1
macOS 10.13.6

Edit: I started grepping around the main manual for <nixpkgs> and found this:

Paths can also be specified between angle brackets, e.g. <nixpkgs> . This means that the directories listed in the environment variable NIX_PATH will be searched for the given file or directory name.

In my case, that’s:


Buuuuut it looks like the channels I am updating are actually at /nix/var/nix/profiles/per-user/brian-hicks (this is where ~/.nix-defexpr/channels links to.)

So what’s going on with my NIX_PATH? Is this the problem? What should I tweak to make it look at the right place? I could just set this in my shell, but that feels like cheating—I’d like to understand the cause here so I can debug it on my own next time.

It seems you’ve been bitten by a rather common issue, namely that root’s channels take precedence on multi-user installations… Which is compounded by weird behaviour of sudo on macOS. Does using sudo -i to get a root shell, then running nix-channel --update in there help?

See also

1 Like

looks like that fixed it, thank you!

Is there a way to get my NIX_PATH set correctly, or do I need to wait until the bug you mentioned is fixed?

Edit: ah boo, now it says that “all build users are in use; consider creating additional users and adding them to the ‘nixbld’ group”. Does this mean I should just switch to a single-user installation? Won’t that be slower to build things?

oh, to conclude this: I switched my installation to a single user and the problem went away. It’s slower now for a lot of things, but I don’t get the “all build users are in use” errors any more. :+1: