-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
antora-lunr-extension: init at 1.0.0-alpha.8 #332341
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
philiptaron
merged 10 commits into
NixOS:master
from
trueNAHO:antora-lunr-extension-init-at-1-0-0-alpha-8
Nov 1, 2024
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
43a1759
maintainers: add naho
trueNAHO 3108e45
antora: move package into pkgs/by-name directory
trueNAHO efc3298
antora: reformat with nixfmt
trueNAHO 915e1b9
antora: sort entries
trueNAHO c7b93d2
antora: declare meta.platforms
trueNAHO 8d93801
antora: declare passthru.updateScript
trueNAHO c5f5cc3
antora-ui-default: init at 0
trueNAHO d5443c9
antora: verify core functionality with a minimal working example
trueNAHO 6248c46
antora-lunr-extension: init at 1.0.0-alpha.8
trueNAHO 4ce5400
antora: add naho as maintainer
trueNAHO File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| { | ||
| 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; | ||
| }; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| { | ||
| fetchFromGitLab, | ||
| lib, | ||
| stdenvNoCC, | ||
| }: | ||
| let | ||
| srcFetchFromGitLab = { | ||
| hash = "sha256-q2FwkwzjanxTIxjMpCyMpzPt782uYZiWVdZ7Eev79oM="; | ||
| owner = "trueNAHO"; | ||
| repo = "antora-ui-default"; | ||
| rev = "83bf9bf5f22a6dee397f8b089eb0315c14a278b5"; | ||
| }; | ||
| in | ||
| stdenvNoCC.mkDerivation { | ||
| pname = "antora-ui-default"; | ||
| version = "0"; | ||
|
|
||
| # The UI bundle is fetched from lib.maintainers.naho's antora-ui-default fork | ||
| # for the following reasons: | ||
| # | ||
| # > The UI bundle is currently unpackaged [1] [2], and only accessible by | ||
| # > fetching the latest GitLab artifact or building from source. Neither | ||
| # > method is reliably reproducible, as artifacts are deleted over time and | ||
| # > building from source requires insecure Node 10. | ||
| # > | ||
| # > The solution is to version control the UI bundle. | ||
| # > | ||
| # > [...] | ||
| # > | ||
| # > [1]: https://gitlab.com/antora/antora-ui-default/-/issues/135 | ||
| # > [2]: https://gitlab.com/antora/antora-ui-default/-/issues/211 | ||
| # > | ||
| # > -- [3] | ||
| # | ||
| # To avoid bloating the repository archive size, the UI bundle is not stored | ||
| # in Nixpkgs. | ||
| # | ||
| # For reference, the UI bundle from [3] is 300K large. | ||
| # | ||
| # [3]: https://gitlab.com/trueNAHO/antora-ui-default/-/commit/83bf9bf5f22a6dee397f8b089eb0315c14a278b5 | ||
trueNAHO marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| src = fetchFromGitLab srcFetchFromGitLab; | ||
|
|
||
| phases = [ "installPhase" ]; | ||
|
|
||
| # Install '$src/ui-bundle.zip' to '$out/ui-bundle.zip' instead of '$out' to | ||
| # prevent the ZIP from being misidentified as a binary [1]. | ||
| # | ||
| # [1]: https://github.com/NixOS/nixpkgs/blob/8885a1e21ad43f8031c738a08029cd1d4dcbc2f7/pkgs/stdenv/generic/setup.sh#L792-L795 | ||
| installPhase = '' | ||
| mkdir --parents "$out" | ||
| cp "$src/ui-bundle.zip" "$out" | ||
| ''; | ||
|
|
||
| meta = { | ||
| description = "Antora default UI bundle"; | ||
| homepage = "https://gitlab.com/antora/antora-ui-default"; | ||
| license = lib.licenses.mpl20; | ||
|
|
||
| longDescription = '' | ||
| > A UI bundle is a [ZIP | ||
| > archive](https://en.wikipedia.org/wiki/Zip_(file_format)) or directory | ||
| > that contains one or more UIs for a site. | ||
| > | ||
| > -- Antora | ||
| > https://docs.antora.org/antora/3.1/playbook/ui-bundle-url | ||
|
|
||
| This UI bundle is available under `$out/ui-bundle.zip` and intended to be | ||
| passed to `antora`'s `--ui-bundle-url` flag or injected into the | ||
| [`ui.bundle.url` | ||
| key](https://docs.antora.org/antora/3.1/playbook/ui-bundle-url/#url-key) | ||
| to avoid irreproducible | ||
| [`https://gitlab.com/antora/antora-ui-default/-/jobs/artifacts/HEAD/raw/build/ui-bundle.zip?job=bundle-stable`](https://gitlab.com/${srcFetchFromGitLab.owner}/${srcFetchFromGitLab.repo}/-/blob/${srcFetchFromGitLab.rev}/README.adoc#user-content-use-the-default-ui) | ||
| references. | ||
| ''; | ||
|
|
||
| maintainers = [ lib.maintainers.naho ]; | ||
| platforms = lib.platforms.all; | ||
| }; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| { | ||
| antora, | ||
| antora-lunr-extension, | ||
| antora-lunr-extension-test ? false, | ||
| antora-ui-default, | ||
| gitMinimal, | ||
| lib, | ||
| stdenvNoCC, | ||
| }: | ||
| stdenvNoCC.mkDerivation { | ||
| name = "${antora.pname}${lib.optionalString antora-lunr-extension-test "-${antora-lunr-extension.pname}"}-test"; | ||
| src = ./minimal_working_example; | ||
|
|
||
| postPatch = | ||
| let | ||
| date = lib.escapeShellArg "1/1/1970 00:00:00 +0000"; | ||
| in | ||
| '' | ||
| # > In order to use a local content repository with Antora, even when using | ||
| # > the worktree (HEAD), the repository must have at least one commit. | ||
| # > | ||
| # > -- https://docs.antora.org/antora/3.1/playbook/content-source-url | ||
| git init && | ||
| GIT_AUTHOR_DATE=${date} \ | ||
| GIT_AUTHOR_EMAIL= \ | ||
| GIT_AUTHOR_NAME=Nixpkgs \ | ||
| GIT_COMMITTER_DATE=${date} \ | ||
| GIT_COMMITTER_EMAIL= \ | ||
| GIT_COMMITTER_NAME=Nixpkgs \ | ||
| git commit --allow-empty --allow-empty-message --message "" | ||
| ''; | ||
|
|
||
| buildPhase = | ||
| let | ||
| playbook = builtins.toFile "antora-playbook.json" ( | ||
| builtins.toJSON { | ||
| content.sources = [ { url = "~+"; } ]; | ||
| runtime.log.failure_level = "warn"; | ||
| } | ||
| ); | ||
| in | ||
| '' | ||
| # The --to-dir and --ui-bundle-url options are not included in the | ||
| # playbook due to Antora and Nix limitations. | ||
| 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"; | ||
| } | ||
| } "${playbook}" | ||
| ''; | ||
|
|
||
| nativeBuildInputs = [ | ||
| antora | ||
| gitMinimal | ||
| ]; | ||
|
|
||
| meta = { | ||
| description = "Reproducible Antora test framework"; | ||
| license = lib.licenses.mit; | ||
| maintainers = [ lib.maintainers.naho ]; | ||
| platforms = lib.platforms.all; | ||
| }; | ||
| } |
7 changes: 7 additions & 0 deletions
7
pkgs/by-name/an/antora/test/minimal_working_example/antora.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| --- | ||
| name: Antora | ||
|
|
||
| nav: | ||
| - modules/ROOT/nav.adoc | ||
|
|
||
| version: ~ |
1 change: 1 addition & 0 deletions
1
pkgs/by-name/an/antora/test/minimal_working_example/modules/ROOT/nav.adoc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| * xref:index.adoc[] |
3 changes: 3 additions & 0 deletions
3
pkgs/by-name/an/antora/test/minimal_working_example/modules/ROOT/pages/index.adoc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| = Antora | ||
|
|
||
| == Minimal Working Example |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to pull this into a local. Just use it down below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this use of a let binding feels a little superfluous. Setting it directly inside the fetchFromGitLab call attributes would be a bit clearer.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to #332341 (comment), I will inline the
pnamevalue. However, thesrcFetchFromGitLabvalues are also used to generate the following documentation URL:https://github.com/NixOS/nixpkgs/blob/b63ef6df743c3164c259524875c896273d0008d5/pkgs/by-name/an/antora-ui-default/package.nix#L34
Should I inline all
srcFetchFromGitLabinstances or onlypname?