2023-08-07 13:18:01 +03:30
|
|
|
{
|
2024-02-03 19:04:09 +01:00
|
|
|
rawModules,
|
2024-02-07 16:50:08 +01:00
|
|
|
helpers,
|
2024-01-12 23:22:03 +01:00
|
|
|
pkgs,
|
|
|
|
}: let
|
2024-02-03 19:04:09 +01:00
|
|
|
pkgsDoc =
|
|
|
|
import (pkgs.applyPatches {
|
|
|
|
name = "nixpkgs-nixvim-doc";
|
|
|
|
src = pkgs.path;
|
|
|
|
patches = [
|
|
|
|
./either_recursive.patch
|
|
|
|
];
|
|
|
|
}) {
|
|
|
|
inherit (pkgs) system;
|
|
|
|
config.allowUnfree = true;
|
|
|
|
};
|
|
|
|
|
|
|
|
inherit (pkgsDoc) lib;
|
|
|
|
|
2024-01-12 23:22:03 +01:00
|
|
|
nixvimPath = toString ./..;
|
2023-08-24 14:50:16 +03:30
|
|
|
|
2024-03-22 12:00:43 +00:00
|
|
|
gitHubDeclaration = user: repo: branch: subpath: {
|
|
|
|
url = "https://github.com/${user}/${repo}/blob/${branch}/${subpath}";
|
2024-01-12 23:22:03 +01:00
|
|
|
name = "<${repo}/${subpath}>";
|
|
|
|
};
|
2023-08-24 14:50:16 +03:30
|
|
|
|
2024-01-12 23:22:03 +01:00
|
|
|
transformOptions = opt:
|
|
|
|
opt
|
|
|
|
// {
|
|
|
|
declarations =
|
|
|
|
map (
|
|
|
|
decl:
|
2024-02-03 19:04:09 +01:00
|
|
|
if lib.hasPrefix nixvimPath (toString decl)
|
2024-01-12 23:22:03 +01:00
|
|
|
then
|
2024-03-22 12:00:43 +00:00
|
|
|
gitHubDeclaration "nix-community" "nixvim" "main"
|
2024-02-03 19:04:09 +01:00
|
|
|
(lib.removePrefix "/" (lib.removePrefix nixvimPath (toString decl)))
|
2024-01-12 23:22:03 +01:00
|
|
|
else if decl == "lib/modules.nix"
|
2024-03-22 12:00:43 +00:00
|
|
|
then gitHubDeclaration "NixOS" "nixpkgs" "master" decl
|
2024-01-12 23:22:03 +01:00
|
|
|
else decl
|
|
|
|
)
|
|
|
|
opt.declarations;
|
2023-08-07 13:18:01 +03:30
|
|
|
};
|
|
|
|
|
2024-02-03 17:45:53 +01:00
|
|
|
nixvmConfigType = lib.mkOptionType {
|
|
|
|
name = "nixvim-configuration";
|
|
|
|
description = "nixvim configuration options";
|
|
|
|
descriptionClass = "noun";
|
|
|
|
# Evaluation is irrelevant, only used for documentation.
|
|
|
|
};
|
|
|
|
|
|
|
|
topLevelModules =
|
|
|
|
[
|
|
|
|
../wrappers/modules/output.nix
|
|
|
|
# Fake module to avoid a duplicated documentation
|
|
|
|
(lib.setDefaultModuleLocation "${nixvimPath}/wrappers/modules/files.nix" {
|
|
|
|
options.files = lib.mkOption {
|
|
|
|
type = lib.types.attrsOf nixvmConfigType;
|
|
|
|
description = "Extra files to add to the runtimepath";
|
|
|
|
example = {
|
|
|
|
"ftplugin/nix.lua" = {
|
|
|
|
options = {
|
|
|
|
tabstop = 2;
|
|
|
|
shiftwidth = 2;
|
|
|
|
expandtab = true;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
})
|
|
|
|
]
|
2024-02-03 19:04:09 +01:00
|
|
|
++ (rawModules pkgsDoc);
|
2024-03-30 14:52:32 +01:00
|
|
|
|
|
|
|
hmOptions =
|
|
|
|
builtins.removeAttrs
|
|
|
|
(lib.evalModules {
|
|
|
|
modules = [
|
|
|
|
(import ../wrappers/modules/hm.nix {inherit lib;})
|
|
|
|
];
|
|
|
|
})
|
|
|
|
.options
|
|
|
|
["_module"];
|
2024-01-12 23:22:03 +01:00
|
|
|
in
|
|
|
|
rec {
|
2024-02-03 19:04:09 +01:00
|
|
|
options-json =
|
|
|
|
(pkgsDoc.nixosOptionsDoc
|
|
|
|
{
|
2024-02-07 16:50:08 +01:00
|
|
|
inherit
|
|
|
|
(lib.evalModules {
|
|
|
|
modules = topLevelModules;
|
|
|
|
specialArgs.helpers = helpers;
|
|
|
|
})
|
|
|
|
options
|
|
|
|
;
|
2024-02-03 19:04:09 +01:00
|
|
|
inherit transformOptions;
|
|
|
|
warningsAreErrors = false;
|
|
|
|
})
|
|
|
|
.optionsJSON;
|
|
|
|
man-docs = pkgsDoc.callPackage ./man {inherit options-json;};
|
2024-01-12 23:22:03 +01:00
|
|
|
}
|
|
|
|
# Do not check if documentation builds fine on darwin as it fails:
|
|
|
|
# > sandbox-exec: pattern serialization length 69298 exceeds maximum (65535)
|
2024-02-03 19:04:09 +01:00
|
|
|
// lib.optionalAttrs (!pkgsDoc.stdenv.isDarwin) {
|
|
|
|
docs = pkgsDoc.callPackage ./mdbook {
|
|
|
|
inherit transformOptions;
|
2024-02-03 17:45:53 +01:00
|
|
|
modules = topLevelModules;
|
2024-03-30 14:52:32 +01:00
|
|
|
inherit helpers hmOptions;
|
2024-01-12 23:22:03 +01:00
|
|
|
};
|
2023-08-07 13:18:01 +03:30
|
|
|
}
|