With this patch applied, "nix-env -qaP -A haskellngPackages" succeeds fine without running out of memory. Thanks to @bennofs for catching this in bbb422af92 (commitcomment-11235596).
bbb422af92 (commitcomment-11235596)
eb2884c12c