nix-community.nixvim/docs/default.nix

79 lines
2 KiB
Nix
Raw Normal View History

2024-07-08 07:32:53 +01:00
{
helpers,
system,
nixpkgs,
nuschtosSearch,
2024-07-08 07:32:53 +01:00
}:
2024-05-05 19:39:35 +02:00
let
# We overlay a few tweaks into pkgs, for use in the docs
pkgs = import ./pkgs.nix { inherit system nixpkgs; };
inherit (pkgs) lib;
2024-07-06 00:22:17 +01:00
nixvimPath = toString ./..;
2023-08-24 14:50:16 +03:30
gitHubDeclaration = user: repo: branch: subpath: {
url = "https://github.com/${user}/${repo}/blob/${branch}/${subpath}";
name = "<${repo}/${subpath}>";
};
2023-08-24 14:50:16 +03:30
2024-05-05 19:39:35 +02:00
transformOptions =
opt:
opt
// {
2024-05-05 19:39:35 +02:00
declarations = map (
decl:
if lib.hasPrefix nixvimPath (toString decl) then
gitHubDeclaration "nix-community" "nixvim" "main" (
lib.removePrefix "/" (lib.removePrefix nixvimPath (toString decl))
)
else if decl == "lib/modules.nix" then
gitHubDeclaration "NixOS" "nixpkgs" "master" decl
else
decl
) opt.declarations;
};
2024-09-20 11:47:57 +01:00
evaledModules = helpers.modules.evalNixvim {
2024-08-02 01:45:45 +01:00
modules = [
{
isDocs = true;
nixpkgs.pkgs = pkgs;
}
2024-08-02 01:45:45 +01:00
];
};
2024-05-05 19:39:35 +02:00
options-json =
(pkgs.nixosOptionsDoc {
2024-08-02 01:45:45 +01:00
inherit (evaledModules) options;
inherit transformOptions;
2024-05-05 19:39:35 +02:00
}).optionsJSON;
in
lib.fix (
self:
{
inherit options-json;
inherit (pkgs) nixos-render-docs;
gfm-alerts-to-admonitions = pkgs.python3.pkgs.callPackage ./gfm-alerts-to-admonitions { };
2024-09-11 19:12:19 +02:00
man-docs = pkgs.callPackage ./man { inherit options-json; };
}
// lib.optionalAttrs (!pkgs.stdenv.isDarwin) {
# NuschtOS/search does not seem to work on darwin
search = nuschtosSearch.packages.mkSearch {
optionsJSON = options-json + "/share/doc/nixos/options.json";
urlPrefix = "https://github.com/nix-community/nixvim/tree/main";
title = "Nixvim options search";
baseHref = "/";
};
# Do not check if documentation builds fine on darwin as it fails:
# > sandbox-exec: pattern serialization length 69298 exceeds maximum (65535)
docs = pkgs.callPackage ./mdbook {
2024-10-21 17:17:15 +01:00
inherit evaledModules transformOptions;
inherit (self) search;
};
}
)