2024-07-08 07:32:53 +01:00
|
|
|
{
|
|
|
|
pkgs ? import <nixpkgs> { config.enableUnfree = true; },
|
2024-07-19 20:14:20 +02:00
|
|
|
nuschtosSearch,
|
2024-07-08 07:32:53 +01:00
|
|
|
}:
|
2024-05-05 19:39:35 +02: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-05-05 19:39:35 +02: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-07-08 07:32:53 +01:00
|
|
|
helpers = import ../lib/helpers.nix {
|
|
|
|
inherit lib;
|
|
|
|
pkgs = pkgsDoc;
|
|
|
|
};
|
2024-07-06 00:22:17 +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-05-05 19:39:35 +02:00
|
|
|
transformOptions =
|
|
|
|
opt:
|
2024-01-12 23:22:03 +01:00
|
|
|
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;
|
2023-08-07 13:18:01 +03:30
|
|
|
};
|
|
|
|
|
2024-07-05 23:26:05 +01:00
|
|
|
modules = [
|
|
|
|
../modules/top-level
|
|
|
|
{ isDocs = true; }
|
|
|
|
];
|
2024-05-05 19:39:35 +02:00
|
|
|
|
|
|
|
hmOptions = builtins.removeAttrs (lib.evalModules {
|
|
|
|
modules = [ (import ../wrappers/modules/hm.nix { inherit lib; }) ];
|
|
|
|
}).options [ "_module" ];
|
2024-07-19 20:14:20 +02:00
|
|
|
|
2024-05-05 19:39:35 +02:00
|
|
|
options-json =
|
|
|
|
(pkgsDoc.nixosOptionsDoc {
|
|
|
|
inherit
|
|
|
|
(lib.evalModules {
|
2024-07-05 16:39:32 +01:00
|
|
|
inherit modules;
|
2024-07-02 13:30:29 +01:00
|
|
|
specialArgs = {
|
|
|
|
inherit helpers;
|
|
|
|
defaultPkgs = pkgsDoc;
|
|
|
|
};
|
2024-02-03 19:04:09 +01:00
|
|
|
})
|
2024-05-05 19:39:35 +02:00
|
|
|
options
|
|
|
|
;
|
2024-02-03 19:04:09 +01:00
|
|
|
inherit transformOptions;
|
2024-05-05 19:39:35 +02:00
|
|
|
warningsAreErrors = false;
|
|
|
|
}).optionsJSON;
|
2024-07-19 20:14:20 +02:00
|
|
|
|
|
|
|
in
|
|
|
|
{
|
|
|
|
inherit options-json;
|
|
|
|
|
2024-05-05 19:39:35 +02:00
|
|
|
man-docs = pkgsDoc.callPackage ./man { inherit options-json; };
|
|
|
|
}
|
2024-07-19 20:14:20 +02:00
|
|
|
// 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
|
2024-07-25 19:21:46 +02:00
|
|
|
search = mkSearch "/nixvim/search/";
|
2024-07-19 20:14:20 +02:00
|
|
|
};
|
|
|
|
}
|
|
|
|
)
|