How to package a LibreOffice extension

I am trying to package the languagetool LibreOffice extension so I can install it declarative, but it looks like LibreOffice is not detecting the extension no matter what I do.

Here is what I have so far:

{ stdenvNoCC
, fetchurl
, lib
, languagetool
, libarchive
}:
stdenvNoCC.mkDerivation rec {
  pname = "libreoffice-extension-languagetool";
  version = "6.1.1";

  src = fetchurl {
    url = "https://languagetool.org/download/LanguageTool-${version}.oxt";
    hash = "sha256-lCSO+KSHUW8M2gkXvxM2/V/FkJSXYN9ZwljYhlv2cUY=";
  };

  # Otherwise, will get "do not know how to unpack .oxt"
  dontUnpack = true;

  # need bsdtar
  nativeBuildInputs = [ libarchive ];
  buildInputs = [ languagetool ];

  installPhase = ''
    runHook preInstall

    install -d -m755 "$out/lib/libreoffice/share/extensions/languagetool/"
    bsdtar -xf $src -C "$out/lib/libreoffice/share/extensions/languagetool/"

    runHook postInstall
  '';

  meta = with lib; {
    homepage = "https://extensions.libreoffice.org/en/extensions/show/languagetool";
    description = "Style and grammar checker support for Libreoffice";
    maintainers = with maintainers; [ anomalocaris ];
    platforms = platforms.linux;
  };
}

I based my approach on that of the AUR package: AUR (en) - libreoffice-extension-languagetool

On NixOS there is no /lib directory that can be seen by all packages. I don’t see a way to provide extension packages to the Libreoffice package. So to do this the Libreoffice package will need to be modified. You can submit an issue to the Nixpkgs repo on github.

Thanks for your answer.

Do you know what kind of changes would have to be made to the LibreOffice package? I would assume it has something to do with the wrapper, right?

We would need a way to inject extensions into the wrapped LO package.

There are many other applications operating within this paradigm in nixpkgs.