diff --git a/docs/default.nix b/docs/default.nix index 043e1c20..8c98743c 100644 --- a/docs/default.nix +++ b/docs/default.nix @@ -1,5 +1,6 @@ { pkgs ? import { 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/"; + }; + } +) diff --git a/docs/mdbook/SUMMARY.md b/docs/mdbook/SUMMARY.md index 9d2f4165..67fbff88 100644 --- a/docs/mdbook/SUMMARY.md +++ b/docs/mdbook/SUMMARY.md @@ -21,3 +21,4 @@ --- [Contributing](./CONTRIBUTING.md) +[NixVim Options Search](./search/index.html) diff --git a/docs/mdbook/default.nix b/docs/mdbook/default.nix index 8ff49328..ad13645d 100644 --- a/docs/mdbook/default.nix +++ b/docs/mdbook/default.nix @@ -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 ''; } diff --git a/flake-modules/packages.nix b/flake-modules/packages.nix index e25d9ac7..873efc71 100644 --- a/flake-modules/packages.nix +++ b/flake-modules/packages.nix @@ -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`. diff --git a/flake.lock b/flake.lock index 99d3151e..9915fd30 100644 --- a/flake.lock +++ b/flake.lock @@ -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" } }, diff --git a/flake.nix b/flake.nix index 7c13175d..9b5244b1 100644 --- a/flake.nix +++ b/flake.nix @@ -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";