2024-07-02 13:30:29 +01:00
|
|
|
{ helpers, pkgs }:
|
2024-01-12 23:22:03 +01:00
|
|
|
let
|
2024-06-05 21:59:34 +02:00
|
|
|
# Extend nixpkg's lib, so that we can handle recursive leaf types such as `either`
|
|
|
|
lib = pkgs.lib.extend (
|
|
|
|
final: prev: {
|
|
|
|
types = prev.types // {
|
|
|
|
either =
|
|
|
|
t1: t2:
|
|
|
|
(prev.types.either t1 t2)
|
|
|
|
// {
|
|
|
|
getSubOptions = prefix: (t1.getSubOptions prefix) // (t2.getSubOptions prefix);
|
|
|
|
};
|
|
|
|
|
|
|
|
eitherRecursive = t1: t2: (final.types.either t1 t2) // { getSubOptions = _: { }; };
|
|
|
|
|
|
|
|
oneOfRecursive =
|
|
|
|
ts:
|
|
|
|
let
|
|
|
|
head' =
|
|
|
|
if ts == [ ] then
|
|
|
|
throw "types.oneOfRecursive needs to get at least one type in its argument"
|
|
|
|
else
|
|
|
|
builtins.head ts;
|
|
|
|
tail' = builtins.tail ts;
|
|
|
|
in
|
|
|
|
builtins.foldl' final.types.eitherRecursive head' tail';
|
2024-02-03 19:04:09 +01:00
|
|
|
};
|
2024-06-05 21:59:34 +02:00
|
|
|
}
|
|
|
|
);
|
2024-02-03 19:04:09 +01:00
|
|
|
|
2024-06-05 21:59:34 +02:00
|
|
|
pkgsDoc = pkgs // {
|
|
|
|
inherit lib;
|
|
|
|
};
|
2024-02-03 19:04:09 +01:00
|
|
|
|
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) 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-05-05 19:39:35 +02:00
|
|
|
)
|
2024-01-12 23:22:03 +01:00
|
|
|
else if decl == "lib/modules.nix" then
|
2024-03-22 12:00:43 +00:00
|
|
|
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 = [
|
2024-07-02 13:30:29 +01:00
|
|
|
../modules
|
2024-02-03 17:45:53 +01:00
|
|
|
../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
|
|
|
};
|
2024-03-30 14:52:32 +01:00
|
|
|
})
|
2024-07-02 13:30:29 +01:00
|
|
|
];
|
2024-05-05 19:39:35 +02:00
|
|
|
|
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;
|
2024-07-02 13:30:29 +01:00
|
|
|
specialArgs = {
|
|
|
|
inherit helpers;
|
|
|
|
defaultPkgs = pkgsDoc;
|
|
|
|
};
|
2024-02-03 19:04:09 +01:00
|
|
|
})
|
|
|
|
options
|
|
|
|
;
|
|
|
|
inherit transformOptions;
|
|
|
|
warningsAreErrors = false;
|
|
|
|
}).optionsJSON;
|
|
|
|
man-docs = pkgsDoc.callPackage ./man { inherit options-json; };
|
2024-05-05 19:39:35 +02:00
|
|
|
}
|
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
|
|
|
}
|