Nix 2 is installed but nixos-rebuild can't find it

How can I tell nixos-rebuild to use it? I get the same error message with the --no-build-nix option.

# nix --version
nix (Nix) 2.3pre6688_bb6e6923

# nixos-rebuild build
building Nix...
error: evaluation aborted with the following error message: ‘
This version of Nixpkgs requires Nix >= 2.0, please upgrade:

Setting _NIXOS_REBUILD_REEXEC=1 seems to work at first, but then Nix 1 download-from-binary-cache.pl gets called.

If you’ve used nix-env -i to install nix2, that probably won’d to you any good. Have you seen the notices regarding nix-2 in the manual?

I just had to wait a little longer. This worked for me:

_NIXOS_REBUILD_REEXEC=1 nixos-rebuild build --no-build-nix

Have you seen the notices regarding nix-2 in the manual?

The documentation you linked to recommends running nixos-rebuild switch, which is what I am trying to do.

It recommends nixos-rebuild switch before you change your channel to 19.03, so the old Nix is switched out while you’re still on your old channel.
Once that is done, you can change to the new channel and the new Nix 2 should be able to build the 19.03 channel.

Glad that you got it working, though.

1 Like