`xdg-mime` doesn't handle magic numbers or subclasses in custom mime-types?

I’m trying to get close to native support for Guitar Pro in my desktop environment. I have an okay first draft at this in my module here, but I’m seeing some inconsistent behavior around mime types.

The relevant snippet from home-manager is:

...
    xdg = {
      dataFile = {
        "mime/packages/guitar-pro.xml" = {
          onChange = "update-mime-database ${config.home.homeDirectory}/.local/share/mime";
          text = ''
            <?xml version="1.0" encoding="UTF-8"?>
            <mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
              <mime-type type="application/x-gtp">
                <comment>Guitar Pro file</comment>
                <glob pattern="*.gtp"/>
                <glob pattern="*.gp3"/>
                <glob pattern="*.gp4"/>
                <glob pattern="*.gp5"/>
                <icon name="emblem-music-symbolic"/>
              </mime-type>
              <mime-type type="application/x-gtp">
                <comment>Guitar Pro file</comment>
                <!-- The file extension gpx is also used for GPX geographic data. Guitar Pro gpx files always begin with "BCFZ" -->
                <magic priority="50">
                  <match value="BCFZ\004" type="string" offset="0" />
                </magic>
                <glob pattern="*.gpx"/>
                <icon name="emblem-music-symbolic"/>
              </mime-type>
              <mime-type type="application/x-gtp">
              <comment>Guitar Pro file</comment>
                <!-- The file extension gp is also used for Gnuplot ASCII data. Guitar Pro gp files are ZIP archives -->
                <sub-class-of type="application/zip"/>
                <glob pattern="*.gp"/>
                <icon name="emblem-music-symbolic"/>
              </mime-type>
            </mime-info>
          '';
        };
      };
      mimeApps = {
        associations.added = {
          "application/x-gtp" = "guitar-pro.desktop";
        };
        defaultApplications = {
          "application/x-gtp" = "guitar-pro.desktop";
        };
      };
    };
...

This almost works perfectly, but xdg-mime seems to struggle with the .gpx and .gp filetypes:

❯ xdg-mime query default application/x-gtp
guitar-pro.desktop

❯ xdg-mime query filetype some_gp5_file.gp5
application/x-gtp

/tank/net/tabs
❯ xdg-mime query filetype some_gpx_file.gpx
application/gpx+xml

/tank/net/tabs
❯ xdg-mime query filetype some_gp_file.gp
application/x-gnuplot

xdg-mime obviously has some knowledge of the mime database, but it doesn’t seem to correctly evaluate the <sub-class-of type="application/zip"/> or <magic> numbers definitions…

The more heavy weight file explorers seem to handle these cases correctly. Both thunar and nautilus work perfectly. I’d love to be able to just xdg-open these files and have them open with the correct software though, so they’d work regardless of how they’re opened or launched.

Does anybody know for sure what xdg-utils is doing differently internally? I’ve been digging around and it seems like it might be using file internally, but that doesn’t seem to explain things either:

❯ file -i some_gp5_file.gp5
some_gp5_file.gp5: application/octet-stream; charset=binary

❯ file -i some_gpx_file.gpx
some_gpx_file.gpx: application/octet-stream; charset=binary

❯ file -i some_gp_file.gp
some_gp_file.gp: application/zip; charset=binary

I’d really appreciate any advice or tips if anybody has any. I’m not sure if this is some kind of nixos specific quirk, or just limitations of xdg-mime. I’d really love to avoid going down the rabbithole of writing magic number files for file and patching them in if at all possible, heh. Thanks.