forked from nix-community/nixvim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdefault.nix
85 lines (75 loc) · 2.28 KB
/
default.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
{
system,
nixpkgs,
nuschtosSearch,
}:
let
# We overlay a few tweaks into pkgs, for use in the docs
pkgs = import ./pkgs.nix { inherit system nixpkgs; };
inherit (pkgs) lib;
helpers = import ../lib { inherit lib pkgs; };
nixvimPath = toString ./..;
gitHubDeclaration = user: repo: branch: subpath: {
url = "https://github.com/${user}/${repo}/blob/${branch}/${subpath}";
name = "<${repo}/${subpath}>";
};
transformOptions =
opt:
opt
// {
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;
};
evaledModules = lib.evalModules {
inherit (helpers.modules) specialArgs;
modules = [
../modules/top-level
{ isDocs = true; }
];
};
hmOptions = builtins.removeAttrs (lib.evalModules { modules = [ ../wrappers/modules/hm.nix ]; })
.options [ "_module" ];
options-json =
(pkgs.nixosOptionsDoc {
inherit (evaledModules) options;
inherit transformOptions;
warningsAreErrors = false;
}).optionsJSON;
in
{
inherit options-json;
inherit (pkgs) nixos-render-docs;
gfm-alerts-to-admonitions = pkgs.python3.pkgs.callPackage ./gfm-alerts-to-admonitions { };
man-docs = pkgs.callPackage ./man { inherit options-json; };
}
// lib.optionalAttrs (!pkgs.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 = pkgs.callPackage ./mdbook {
inherit evaledModules hmOptions transformOptions;
# TODO: Find how to handle stable when 24.11 lands
search = mkSearch "/nixvim/search/";
};
}
)