Installing gnome 40 on latest NixOS Unstable

You would need to create an overlay with the old packages and some dependencies, plus replace the NixOS modules, similarly to Gnome 3.38 on latest release - #3 by jtojnar. It is possible but probably too much effort – the difference is so large at this point, you would probably need to modify tens or hundreds of packages, fixing the failing builds one by one.