Using Nix 2.6 in NixOS 21.11

Ah, I live in the future, for those exact reasons, but assume people don’t if they ask questions so I don’t overload them with a bunch of flakes context when they’re learning :wink: Point out you’re using flakes when asking, that makes it easier to pin down what answer you’re looking for.

It’s much, much nicer with flakes. You would add a second input for unstable:

{
  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixos-21.11";
    nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable";
  };

  outputs = { nixpkgs, nixpkgs-unstable, ... }: { }

As with flakes in general, this gives you pinning through flake.lock, and sorts out pulling in updates with nix flake update.

Then, the choice is yours. You need to take that nixpkgs-unstable, and
somehow prop it into the same place you define nix.package. You can
do that via an overlay, _module.args, or simply by setting
nix.package in flake.nix, so you still have access to that
nixpkgs-unstable variable.

There’s this recent question that has some discussion on the benefits of the various ways you can do that: Install agenix in "environment.systemPackages" on nixos with flakes

Note that nixpkgs exposes its packages through nixpkgs-unstable.legacyPackages, so if I’m not mistaken a direct reference to nix 2.6 would be nixpkgs-unstable.legacyPackages."x86_64".nix_2_6.