Why removing GNOME from my system removes the backgrounds directory as well?

I created a NixOS config that automatically installs wallpapers to /run/current-system/sw/share/backgrounds using code like this:

  wallpapersPackage = pkgs.runCommand "system-wallpapers" { } ''
    mkdir -p $out/share/backgrounds/dark
    ${lib.concatMapStringsSep "\n" (w: "cp ${w.src} $out/share/backgrounds/dark") wallpapers}
    ln -s $out/share/backgrounds/dark/* $out/share/backgrounds
  '';

(and similar code for the light images).
And it works until I remove this line from my config:

services.desktopManager.gnome.enable = true;

But why? Isn’t this code supposed to create the backgrounds directory automatically? I though mkdir -p $out/share/backgrounds/dark should do exactly that.

Looks like it’s due to the following lines in the GNOME module:

environment.pathsToLink = [
“/share” # TODO: https://github.com/NixOS/nixpkgs/issues/47173
];

I tried adding these lines to my config and it seems to fix the issue. Thanks!