Nix command version upgrade

I am using NixOS with channel nixos-21.11 release nixos-21.11.337975.eabc3821918 with configuration.nix entry

  nix = {
    package = pkgs.nixFlakes;
    extraOptions = ''                                                                                   
       experimental-features = nix-command flakes                                                                                                                      
       '';
  };

and the nix --version returns nix (Nix) 2.4. How can I upgrade the nix command to something more recent?

λ ~/ nix --version
nix (Nix) 2.4
λ ~/ nix shell nixpkgs#nix
λ ~/ nix --version        
nix (Nix) 2.11.0

… but how to make version 2.11 native?

Note that starting with 22.05 nix refers to Nix with flakes support, so nixFlakes is not needed anymore. The latest version that nixos-21.11 branch provides is nix_2_7.
If you want to install the very latest version of something, you would have to use unstable channel, but you can stay on stable channel for everything else. To do this, add nixos-unstable channel to your system, and then you can use

nix = {
  package = (import <nixos-unstable> {}).nix;
  ...
}
2 Likes

On a separate note - you absolutely want to update to 22.05 as 21.11 is no longer getting security updates.

2 Likes