Merging directories in home-manager

I would like to merge two icon themes (that do not share any icons). A single Icon theme can be symlinked by home-manager like this:

home.file.".local/share/icons/Adwaita".source = "${pkgs.gnome.adwaita-icon-theme}/share/themes/Adwaita";

(although I don’t know if this is the correct way to do that)

I would like something that works kind of like this:

home.file.".local/share/icons/Adwaita" = {
    source = "${pkgs.gnome.adwaita-icon-theme}/share/themes/Adwaita";
    recursive = true;
};
home.file.".local/share/icons/Adwaita" = {
    source = ./adwaita-patch;
    recursive = true;
};

But of course you can’t have the same attribute name twice. I saw symlinkJoin exists, but only as the builder of a derivation. Do I have to create a new derivation that essentially just copies files, or can I do this somehow directly in the home-manager config?

I’d reccomend overriding the original package and applying your patch using the patch support:

let
  patched-adwaita = pkgs.gnome.adwaita-icon-theme.overrideAttrs(old: {
    patches = old.patches ++ [ ./adwaita.patch ];
  });
in
  home.file.".local/share/icons/Adwaita".source = "${patched-adwaita}/share/themes/Adwaita";

You can also use postInstall to use a script to change the package instead if you’re literally copying files:

let
  patched-adwaita = pkgs.gnome.adwaita-icon-theme.overrideAttrs(old: {
    postInstall = ''
      cp ${./adwaita-patch}/. $out/share/themes/Adwaita
    '';
  });
in
  home.file.".local/share/icons/Adwaita".source = "${patched-adwaita}/share/themes/Adwaita";

And by the way, home-manager supports setting the icon theme without symlinks:

gtk.iconTheme = {
  package = patched-adwaita;
  name = "Adwaita";
};

Thank you, using the postInstall hook worked!