How to correctly install a specific version of node

I am trying to setup a default.nix file that will have a specific version of node and yarn. I have successfully created this file like this:

let
  pkgs = import (fetchTarball https://github.com/NixOS/nixpkgs/archive/1b9e74a8ded639e1d4da83a2c8656458cb048cd9.tar.gz) {};
in
  pkgs.mkShell {
    buildInputs = [
      pkgs.nodejs-16_x
    ];
  }

Notice that I have had to set the pkgs variable to a specific revision. This specific revision means that I changed the versions of everything.

Is there any other way? Is it not possible to install node at version 16.13.1 without having to go to an older version of all packages?

You can specify as many versions of Nixpkgs as you want in additional bindings:

let
  pkgs = import (fetchTarball ...) {};
  pkgs2 = import (fetchTarball ...) {};
in
  pkgs.mkShell {
    buildInputs = [
      pkgs2.nodejs-16_x
    ];
  }

Oh dang!! Why didn’t I think of that! Thank you so much! This makes a ton of sense! :heart: