Is `nix-channel --update` broken in Nix 2.1 on Darwin?

I’ve just upgraded to nix 2.1 with nix upgrade-nix, and nix-channel --update does not work anymore:

% nix-channel --update
unpacking channels...
error: unsupported builtin function 'buildenv'
builder for '/nix/store/xyqcscjac7bndrb7ycwi374xy6qx0vhw-user-environment.drv' failed with exit code 1
error: build of '/nix/store/xyqcscjac7bndrb7ycwi374xy6qx0vhw-user-environment.drv' failed
error: program '/nix/store/n7fvy0k555gwkkdszdkhi3h0aahca8h3-nix-2.1/bin/nix-env' failed with exit code 100

Is this a bug?

This means nix wasn’t upgraded correctly, I suspect you have 2 versions of nix in PATH and only the first (just client) was upgraded.

No, I have only nix in my PATH, in /nix/var/nix/profiles/default/bin/.

However, I found out that nix-channel --update works fine when prefixed with sudo:

% sudo nix-channel --update
unpacking channels...
created 5 symlinks in user environment

That’s a bit confusing…

1 Like

Strange, could you try these instructions Introduction.

I’ve “fixed” by re-installing ‘nix’ from scratch. I don’t know what happened.

What is the difference between nix upgrade-nix and the upgrade method that is recommended in the manual (that is nix-env -iA nixpkgs.nix)?

Hm, I faced the same today.
Running sudo nix-channel --update once fixed it for me.
Wasn’t that sufficient for your setup as well?