Nested package sets in flakes

The global package-set of “nixpkgs” contains a layer of recursion which allows to contain itself package sets. This is frequently used to collect packages for a specific software or environment. Examples are python311Packages, haskellPackages, emacsPackages terraform-providers and much more.

How can I define such a package-sub-set in a flake? I expect that this must somehow work as it works for the top-level-flake of nixpkgs. However I was not able to figure it out how.

{
  description = "A very basic flake";

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

  outputs = { self, nixpkgs }: {
    packages.x86_64-linux =
      let
        lib = nixpkgs.lib;
        pkgs = nixpkgs.legacyPackages.x86_64-linux;
      in {
        default = self.packages.x86_64-linux.hello;

        hello = pkgs.hello;
        single_tf_plugin = pkgs.terraform-providers.aws; # Works! But is a single derivation, not a package set.
        # own-tf-providers1 = pkgs.terraform-providers; # Fails! “[…] is not a derivation”
        own-tf-providers2 = lib.recurseIntoAttrs {
          aws = pkgs.terraform-providers.aws;
          azuread = pkgs.terraform-providers.azuread;
          # […] more providers
        }; # Fails! “[…] is not a derivation”
      };
  };
}

I would have expected both to work, “own-tf-providers1” (as it works for nixpkgs) and “own-tf-providers2” (described here).

It looks like this actually is a currently open issue: https://github.com/NixOS/nix/issues/9346