Skip to content

Commit

Permalink
docs: Add an option search to our documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
traxys authored and GaetanLepage committed Jul 25, 2024
1 parent 30ab203 commit 42a7676
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 19 deletions.
49 changes: 35 additions & 14 deletions docs/default.nix
Original file line number Diff line number Diff line change
@@ -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`
Expand Down Expand Up @@ -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
Expand All @@ -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/";
};
}
)
1 change: 1 addition & 0 deletions docs/mdbook/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@
---

[Contributing](./CONTRIBUTING.md)
[NixVim Options Search](./search/index.html)
3 changes: 3 additions & 0 deletions docs/mdbook/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
nixosOptionsDoc,
transformOptions,
hmOptions,
search,
}:
with lib;
let
Expand Down Expand Up @@ -268,5 +269,7 @@ pkgs.stdenv.mkDerivation {
${prepareMD}
mdbook build
cp -r ./book/* $dest
mkdir -p $dest/search
cp -r ${search}/* $dest/search
'';
}
8 changes: 7 additions & 1 deletion flake-modules/packages.nix
Original file line number Diff line number Diff line change
@@ -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`.
Expand Down
33 changes: 29 additions & 4 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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";
Expand Down

0 comments on commit 42a7676

Please sign in to comment.