docs: Add an option search to our documentation

This commit is contained in:
traxys 2024-07-19 20:14:20 +02:00 committed by GaetanLepage
parent 30ab203d56
commit 42a7676d5a
6 changed files with 81 additions and 19 deletions

View file

@ -1,5 +1,6 @@
{
pkgs ? import <nixpkgs> { config.enableUnfree = true; },
nuschtosSearch,
}:
let
# Extend nixpkg's lib, so that we can handle recursive leaf types such as `either`
@ -71,8 +72,7 @@ let
hmOptions = builtins.removeAttrs (lib.evalModules {
modules = [ (import ../wrappers/modules/hm.nix { inherit lib; }) ];
}).options [ "_module" ];
in
rec {
options-json =
(pkgsDoc.nixosOptionsDoc {
inherit
@ -88,17 +88,38 @@ rec {
inherit transformOptions;
warningsAreErrors = false;
}).optionsJSON;
in
{
inherit options-json;
man-docs = pkgsDoc.callPackage ./man { inherit options-json; };
}
# Do not check if documentation builds fine on darwin as it fails:
# > sandbox-exec: pattern serialization length 69298 exceeds maximum (65535)
// lib.optionalAttrs (!pkgsDoc.stdenv.isDarwin) {
docs = pkgsDoc.callPackage ./mdbook {
inherit
helpers
modules
hmOptions
transformOptions
;
};
}
// lib.optionalAttrs (!pkgsDoc.stdenv.isDarwin) (
let
mkSearch =
baseHref:
nuschtosSearch.packages.mkSearch {
optionsJSON = options-json + "/share/doc/nixos/options.json";
urlPrefix = "https://github.com/nix-community/nixvim/tree/main";
inherit baseHref;
};
in
{
# NuschtOS/search does not seem to work on darwin
search = mkSearch "/";
# Do not check if documentation builds fine on darwin as it fails:
# > sandbox-exec: pattern serialization length 69298 exceeds maximum (65535)
docs = pkgsDoc.callPackage ./mdbook {
inherit
helpers
modules
hmOptions
transformOptions
;
# TODO: Find how to handle stable when 24.11 lands
search = mkSearch "/search/";
};
}
)

View file

@ -21,3 +21,4 @@
---
[Contributing](./CONTRIBUTING.md)
[NixVim Options Search](./search/index.html)

View file

@ -6,6 +6,7 @@
nixosOptionsDoc,
transformOptions,
hmOptions,
search,
}:
with lib;
let
@ -268,5 +269,7 @@ pkgs.stdenv.mkDerivation {
${prepareMD}
mdbook build
cp -r ./book/* $dest
mkdir -p $dest/search
cp -r ${search}/* $dest/search
'';
}

View file

@ -1,10 +1,16 @@
{
perSystem =
{ pkgsUnfree, config, ... }:
{
pkgsUnfree,
config,
inputs',
...
}:
{
packages = import ../docs {
# Building the docs evaluates each plugin's default package, some of which are unfree
pkgs = pkgsUnfree;
inherit (inputs') nuschtosSearch;
};
# Test that all packages build fine when running `nix flake check`.

33
flake.lock generated
View file

@ -2,7 +2,10 @@
"nodes": {
"devshell": {
"inputs": {
"flake-utils": "flake-utils",
"flake-utils": [
"nuschtosSearch",
"flake-utils"
],
"nixpkgs": [
"nixpkgs"
]
@ -60,11 +63,11 @@
"systems": "systems"
},
"locked": {
"lastModified": 1701680307,
"narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=",
"lastModified": 1710146030,
"narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "4022d587cbbfd70fe950c1e2083a02621806a725",
"rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
"type": "github"
},
"original": {
@ -177,6 +180,27 @@
"type": "github"
}
},
"nuschtosSearch": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1721332622,
"narHash": "sha256-04AOrnpZIz15AXXlVWKRmZwbFgI/pjC8AaQ+T6VlFMc=",
"owner": "NuschtOS",
"repo": "search",
"rev": "b5990bce952c39824169dad255ff39c8abe4ca21",
"type": "github"
},
"original": {
"owner": "NuschtOS",
"repo": "search",
"type": "github"
}
},
"root": {
"inputs": {
"devshell": "devshell",
@ -186,6 +210,7 @@
"home-manager": "home-manager",
"nix-darwin": "nix-darwin",
"nixpkgs": "nixpkgs",
"nuschtosSearch": "nuschtosSearch",
"treefmt-nix": "treefmt-nix"
}
},

View file

@ -33,6 +33,11 @@
```
*/
nuschtosSearch = {
url = "github:NuschtOS/search";
inputs.nixpkgs.follows = "nixpkgs";
};
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
@ -45,6 +50,7 @@
devshell = {
url = "github:numtide/devshell";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-utils.follows = "nuschtosSearch/flake-utils";
};
treefmt-nix = {
url = "github:numtide/treefmt-nix";