Unverified Commit 6248c46b authored by NAHO's avatar NAHO
Browse files

antora-lunr-extension: init at 1.0.0-alpha.8

parent d5443c91
Loading
Loading
Loading
Loading
+63 −0
Original line number Diff line number Diff line
{
  antora,
  buildNpmPackage,
  fetchFromGitLab,
  lib,
  nix-update-script,
}:
buildNpmPackage rec {
  pname = "antora-lunr-extension";
  version = "1.0.0-alpha.8";

  src = fetchFromGitLab {
    hash = "sha256-GplCwhUl8jurD4FfO6/T3Vo1WFjg+rtAjWeIh35unk4=";
    owner = "antora";
    repo = pname;
    rev = "v${version}";
  };

  npmDepsHash = "sha256-EtjZL6U/uSGSYSqtuatCkdWP0NHxRuht13D9OaM4x00=";

  # Prevent tests from failing because they are fetching data at runtime.
  postPatch = ''
    substituteInPlace package.json --replace '"_mocha"' '""'
  '';

  # Pointing $out to $out/lib/node_modules/@antora/lunr-extension simplifies
  # Antora's extension option usage from
  #
  #     --extension ${pkgs.antora-lunr-extension}/lib/node_modules/@antora/lunr-extension
  #
  # to
  #
  #     --extension ${pkgs.antora-lunr-extension}
  postInstall = ''
    directory="$(mktemp --directory)"

    mv "$out/"{.,}* "$directory"
    mv "$directory/lib/node_modules/@antora/lunr-extension/"{.,}* "$out"
  '';

  passthru = {
    tests.run = antora.tests.run.override {
      antora-lunr-extension-test = true;
    };

    updateScript = nix-update-script { };
  };

  meta = {
    description = "Antora extension adding offline, full-text search powered by Lunr";
    homepage = "https://gitlab.com/antora/antora-lunr-extension";
    license = lib.licenses.mpl20;

    longDescription = ''
      This Antora extension is intended to be passed to `antora`'s `--extension`
      flag or injected into the [`antora.extensions`
      key](https://docs.antora.org/antora/3.1/extend/enable-extension).
    '';

    maintainers = [ lib.maintainers.naho ];
    platforms = lib.platforms.all;
  };
}
+4 −1
Original line number Diff line number Diff line
{
  antora,
  antora-lunr-extension,
  antora-lunr-extension-test ? false,
  antora-ui-default,
  gitMinimal,
  lib,
  stdenvNoCC,
}:
stdenvNoCC.mkDerivation {
  name = "${antora.pname}-test";
  name = "${antora.pname}${lib.optionalString antora-lunr-extension-test "-${antora-lunr-extension.pname}"}-test";
  src = ./minimal_working_example;

  postPatch =
@@ -43,6 +45,7 @@ stdenvNoCC.mkDerivation {
      antora ${
        lib.cli.toGNUCommandLineShell { } {
          cache-dir = "$(mktemp --directory)";
          extension = if antora-lunr-extension-test then antora-lunr-extension else false;
          to-dir = placeholder "out";
          ui-bundle-url = "${antora-ui-default}/ui-bundle.zip";
        }