How to use fix for Flatpak apps cursor theme?

Hi. There’s Flatpak can't access system fonts and icons · Issue #119433 · NixOS/nixpkgs · GitHub a fix for flatpak cursor theme and fonts. But I cannot use it in my config without error: infinite recursion encountered. Can someone explain how to edit my .nix files to use that fix?

My config is here GitHub - knightpp/nixos-cfg at flatpak-fix, please note, I did not write the config by myself, and I’m still learning Nix.

I wonder how can I access config.fonts.fonts or config.fonts.fonts outside of NixOS modules? I do not see the necessary arguments anywhere else, so I tried to use modules but get an error when I use workarounds.flatpak.enable = true

# nixos-rebuild dry-build
error: infinite recursion encountered

       at /nix/store/rwg22rlfgk967c9grlpba44m3ydrk8iy-source/lib/modules.nix:951:14:

          950|     { _type = "if";
          951|       inherit condition content;
             |              ^
          952|     };
(use '--show-trace' to show detailed location information)

Here’s module’s code (or see GitHub page)

{ config, lib, pkgs, ... }:
let
  cfg = config.workarounds.flatpak;
  inherit (lib) types mkOption mkIf;
in
{
  options.workarounds.flatpak = {
    enable = mkOption {
      description = "Enable workarounds for flatpak";
      type = types.bool;
      default = false;
    };

    # fonts = mkOption {
    #   description = "config.fonts.fonts package";
    #   type = types.package;
    # };

    # systemPath = mkOption {
    #   description = "config.system.path package";
    #   type = types.package;
    # };
  };
  config = mkIf cfg.enable {
    # Allow flatpak to read system icons 
    system.fsPackages = [ pkgs.bindfs ];
    fileSystems =
      let
        mkRoSymBind = path: {
          device = path;
          fsType = "fuse.bindfs";
          options = [ "ro" "resolve-symlinks" "x-gvfs-hide" ];
        };
        # aggregatedFonts = pkgs.buildEnv {
        #   name = "system-fonts";
        #   paths = cfg.fonts;
        #   pathsToLink = [ "/share/fonts" ];
        # };
      in
      {
        # Create an FHS mount to support flatpak host icons/fonts
        "/usr/share/icons" = mkRoSymBind (config.system.path + "/share/icons");
        # "/usr/share/fonts" = mkRoSymBind (aggregatedFonts + "/share/fonts");
      };
  };
}

One possible solution is to hardcode fonts and icons

{ config, pkgs, ... }: {
  system.fsPackages = [ pkgs.bindfs ];
  fileSystems =
    let
      mkRoSymBind = path: {
        device = path;
        fsType = "fuse.bindfs";
        options = [ "ro" "resolve-symlinks" "x-gvfs-hide" ];
      };
      aggregated = pkgs.buildEnv {
        name = "system-fonts-and-icons";
        paths = with pkgs;[
          libsForQt5.breeze-qt5

          noto-fonts
          noto-fonts-emoji
          noto-fonts-cjk-sans
          noto-fonts-cjk-serif
        ];
        pathsToLink = [ "/share/fonts" "/share/icons" ];
      };
    in
    {
      # Create an FHS mount to support flatpak host icons/fonts
      "/usr/share/icons" = mkRoSymBind "${aggregated}/share/icons";
      "/usr/share/fonts" = mkRoSymBind "${aggregated}/share/fonts";
    };
}