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

#1

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:
0 Likes

#2

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

0 Likes

#3

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?
https://nixos.org/nixos/manual/release-notes.html#sec-release-19.03-incompatibilities

0 Likes

#4

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.

0 Likes

#5

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.

0 Likes