Set nix.package
in your NixOS config and rebuild, if you want some version other than the current stable (2.18.x), but be aware that this can lead to regressions.
Not sure how your nix profile got broken like this, but in general, never run nix upgrade-nix
on NixOS - you have a NixOS config for a reason. Managing nix imperatively is essentially fighting the benefits of using NixOS.